diff options
Diffstat (limited to 'tests/run.sh')
| -rw-r--r-- | tests/run.sh | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/tests/run.sh b/tests/run.sh index 6b3bb00..7626424 100644 --- a/tests/run.sh +++ b/tests/run.sh @@ -2,29 +2,47 @@ set -e export ducc="../../../build/$BIN" -export testcase=$1 +arg=$1 +export testcase="${arg%.sh}" +testcase="${testcase%.c}" export tmp_dir="tests/tmp/$testcase" -c_test_file="tests/$testcase.c" -sh_test_file="tests/$testcase.sh" +run_c=0 +run_sh=0 +if [[ "$arg" == *.c ]]; then + run_c=1 +elif [[ "$arg" == *.sh ]]; then + run_sh=1 +else + run_c=1 + run_sh=1 +fi -if [[ -f "$c_test_file" ]]; then +found=0 + +if [[ $run_c -eq 1 && -f "tests/$testcase.c" ]]; then + found=1 source tests/helpers.sh - echo "$c_test_file" + echo "tests/$testcase.c" mkdir -p "$tmp_dir" cd "$tmp_dir" - test_exit_code 0 < "../../../$c_test_file" + test_exit_code 0 < "../../../tests/$testcase.c" cd "../../.." -elif [[ -f "$sh_test_file" ]]; then +fi + +if [[ $run_sh -eq 1 && -f "tests/$testcase.sh" ]]; then + found=1 source tests/helpers.sh - echo "$sh_test_file" + echo "tests/$testcase.sh" mkdir -p "$tmp_dir" cd "$tmp_dir" - source "../../../$sh_test_file" + source "../../../tests/$testcase.sh" cd "../../.." -else +fi + +if [[ $found -eq 0 ]]; then echo "no test $testcase" >&2 exit 1 fi |
