From 2009a26e17ad9dbefee3a5ca4339d754e51ef078 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 15 Feb 2026 00:04:23 +0900 Subject: refactor: write more tests in C --- tests/run.sh | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'tests/run.sh') 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 -- cgit v1.3-1-g0d28