aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/run.sh
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-15 00:04:23 +0900
committernsfisis <nsfisis@gmail.com>2026-02-15 00:04:23 +0900
commit2009a26e17ad9dbefee3a5ca4339d754e51ef078 (patch)
tree5c311a1a17f40786f53f4a89c5bbbb72402a6b2d /tests/run.sh
parentef0cb4dbdc1c036f70f94a905cbacae9be5abf5e (diff)
downloadducc-2009a26e17ad9dbefee3a5ca4339d754e51ef078.tar.gz
ducc-2009a26e17ad9dbefee3a5ca4339d754e51ef078.tar.zst
ducc-2009a26e17ad9dbefee3a5ca4339d754e51ef078.zip
refactor: write more tests in C
Diffstat (limited to 'tests/run.sh')
-rw-r--r--tests/run.sh38
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