Skip to content

Commit

Permalink
Add smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Oct 31, 2023
1 parent 9a92688 commit c96c11c
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bin/run-tests-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ docker run \
--rm \
--network none \
--read-only \
--mount type=bind,src="${PWD}/tests",dst=/opt/analyzer/tests \
--mount type=bind,src="${PWD}/snippets",dst=/opt/analyzer/snippets \
--mount type=tmpfs,dst=/tmp \
--volume "${PWD}/bin/run-tests.sh:/opt/analyzer/bin/run-tests.sh" \
--workdir /opt/analyzer \
Expand Down
19 changes: 10 additions & 9 deletions bin/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@
exit_code=0

# Iterate over all test directories
for test_dir in tests/*; do
for analysis_file in $(find snippets -name expected_analysis.json); do
test_dir=$(dirname "${analysis_file}")
test_dir_name=$(basename "${test_dir}")
test_dir_path=$(realpath "${test_dir}")
slug=$(echo $test_dir | awk -F '/' '{ print $2 }')

bin/run.sh "${test_dir_name}" "${test_dir_path}" "${test_dir_path}"
bin/run.sh "${slug}" "${test_dir_path}" "${test_dir_path}"

for file in analysis.json tags.json; do
expected_file="expected_${file}"
echo "${test_dir_name}: comparing ${file} to ${expected_file}"
file="analysis.json"
expected_file="expected_${file}"
echo "${test_dir_name}: comparing ${file} to ${expected_file}"

if ! diff "${test_dir_path}/${file}" "${test_dir_path}/${expected_file}"; then
exit_code=1
fi
done
if ! diff "${test_dir_path}/${file}" "${test_dir_path}/${expected_file}"; then
exit_code=1
fi
done

exit ${exit_code}
4 changes: 4 additions & 0 deletions snippets/reverse-string/approve_1/expected_analysis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"status": "approve",
"comments": []
}
4 changes: 4 additions & 0 deletions snippets/reverse-string/approve_2/expected_analysis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"status": "approve",
"comments": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"status": "approve",
"comments": [
"rust.reverse-string.suggest_doing_bonus_test"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"status": "approve",
"comments": [
"rust.reverse-string.suggest_doing_bonus_test"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"status": "approve",
"comments": [
"rust.reverse-string.suggest_removing_extern_crate"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"status": "approve",
"comments": [
"rust.reverse-string.suggest_removing_extern_crate"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"status": "disapprove",
"comments": [
"rust.reverse-string.solution_function_not_found"
]
}

0 comments on commit c96c11c

Please sign in to comment.