Skip to content

Commit

Permalink
Simplify run-tests.sh (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom authored Sep 27, 2023
1 parent b72e1b4 commit fdd21eb
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions bin/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,22 @@ exit_code=0
for test_dir in tests/*; do
test_dir_name=$(basename "${test_dir}")
test_dir_path=$(realpath "${test_dir}")
results_file_path="${test_dir_path}/results.json"
expected_results_file_path="${test_dir_path}/expected_results.json"

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

# OPTIONAL: Normalize the results file
# If the results.json file contains information that changes between
# different test runs (e.g. timing information or paths), you should normalize
# the results file to allow the diff comparison below to work as expected
# sed -i -E \
# -e 's/Elapsed time: [0-9]+\.[0-9]+ seconds//g' \
# -e "s~${test_dir_path}~/solution~g" \
# "${results_file_path}"

echo "${test_dir_name}: comparing results.json to expected_results.json"
diff "${results_file_path}" "${expected_results_file_path}"
for file in results.json; do
expected_file="expected_${file}"
echo "${test_dir_name}: comparing ${file} to ${expected_file}"

if [ $? -ne 0 ]; then
exit_code=1
fi
if ! diff "${test_dir_path}/${file}" "${test_dir_path}/${expected_file}"; then
exit_code=1
fi
done
done

exit ${exit_code}

0 comments on commit fdd21eb

Please sign in to comment.