Skip to content

Commit

Permalink
improved test_runner.sh output formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
asmuth committed May 9, 2020
1 parent 06830f3 commit 63c0648
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions test/test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,43 @@ run_all_tests() {
num_fail=0

test_cases=$(cd "${source_path}/test" && find . -name "*.clp" ! -path "./spec/*" | sort)
test_cases_failed=()

for test_id in ${test_cases[@]}; do
local test_id="$(echo "${test_id}" | sed -e 's/^.\///' -e 's/\.clp$//')"
num_total=$[ $num_total + 1 ]

if run_test "${test_id}" &>/dev/null; then
echo "$(printf "\033[1;32m%s\033[0m" "[PASS]") ${test_id}"
num_pass=$[ $num_pass + 1 ]
num_pass=$[ $num_pass + 1 ]
else
echo "$(printf "\033[1;31m%s\033[0m" "[FAIL]") ${test_id}"
num_fail=$[ $num_fail + 1 ]
num_fail=$[ $num_fail + 1 ]
test_cases_failed="${test_cases_failed[@]} ${test_id}"
fi
done

if [[ ${num_total} == ${num_pass} ]]; then
echo
echo "TEST RESULT: $(printf "\033[1;32m%s\033[0m" "PASS")"
echo
echo "${num_pass}/${num_total} test cases ok"
exit 0
echo "$(printf "\033[1;32m%s\033[0m" "[PASS]") ${num_pass}/${num_total} test cases passed"
else
echo
echo "Test Result: $(printf "\033[1;31m%s\033[0m" "FAIL")"
echo "$(printf "\033[1;31m%s\033[0m" "[FAIL]") ${num_fail}/${num_total} test cases failed"
fi

for test_id in ${test_cases_failed[@]}; do
echo
echo
echo "${num_fail}/${num_total} test cases failed"
exit 1
echo "$(printf "\033[1;31m%s\033[0m" "FAILED:") test/${test_id}.clp"
echo "-------------------------------------------------------------------"
cat "${result_path}/${test_id}.log"
echo "-------------------------------------------------------------------"
done

if [[ ${num_total} == ${num_pass} ]]; then
exit 0
else
exit 1
fi
}

Expand Down Expand Up @@ -103,6 +114,9 @@ run_test() {
return 0
else
echo "FAIL" >&2
echo "ERROR: output file does not match" >> ${logfile}
echo "ERROR: output: ${outfile}" >> ${logfile}
echo "ERROR: expected: ${reffile}" >> ${logfile}
log_failure "${test_id}" "${outfile}" "${reffile}" "${logfile}"
cat ${logfile}
return 1
Expand Down

0 comments on commit 63c0648

Please sign in to comment.