forked from exercism/groovy-test-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-tests.sh
executable file
·42 lines (32 loc) · 1.12 KB
/
run-tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /bin/sh
# Synopsis:
# Test the test runner 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.
# Example:
# ./bin/run-tests.sh
exit_code=0
# 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="results.json"
results_file_path="${test_dir}/results.json"
expected_results_file="expected_results.json"
expected_results_file_path="${test_dir}/expected_results.json"
bin/run.sh "${test_dir_name}" "${test_dir}" "${test_dir}"
# Normalize the results file
sed -i -E \
-e 's/ in [0-9]+m?s$//g' \
-e "s~${test_dir_path}~/solution~g" \
-e "s/${exercise}@[a-z0-9]+/${exercise}/g" \
"${results_file_path}"
echo "${test_dir_name}: comparing ${results_file} to ${expected_results_file}"
diff "${results_file_path}" "${expected_results_file_path}"
if [ $? -ne 0 ]; then
exit_code=1
fi
done
exit ${exit_code}