-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dce72dc
commit a486c17
Showing
2 changed files
with
16 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,37 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Synopsis: | ||
# Test the test runner by running it against a predefined set of solutions | ||
# Test the representer by running it against a predefined set of solutions | ||
# with an expected output. | ||
|
||
# Output: | ||
# Outputs the diff of the expected test results against the actual test results | ||
# generated by the test runner. | ||
# Outputs the diff of the expected representation files against the | ||
# actual representation files generated by the test runner. | ||
|
||
# Example: | ||
# ./bin/run-tests.sh | ||
|
||
exit_code=0 | ||
filenames="representation.txt mapping.json" | ||
|
||
# Iterate over all test directories | ||
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}" | ||
|
||
if [ $? -ne 0 ]; then | ||
exit_code=1 | ||
fi | ||
for filename in $filenames; do | ||
actual_filepath="${test_dir_path}/${filename}" | ||
expected_filepath="${test_dir_path}/expected_${filename}" | ||
|
||
echo "${test_dir_name}: comparing ${filename} to expected_${filename}" | ||
diff "${actual_filepath}" "${expected_filepath}" | ||
|
||
if [ $? -ne 0 ]; then | ||
exit_code=1 | ||
fi | ||
done | ||
done | ||
|
||
exit ${exit_code} |