summaryrefslogtreecommitdiffhomepage
path: root/run_tests.sh
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-03-11 11:26:55 +0100
committerJo-Philipp Wich <jo@mein.io>2021-03-11 11:33:21 +0100
commit29a5ab1d6e0f3d54de629e10376435e53c6a3121 (patch)
tree3e32b60059b50fd8750b94525e3027d5a66006ec /run_tests.sh
parent6d0b7a8c38e8283bbe91053cbd650af9a36aa4d4 (diff)
run_tests.sh: add various fixes and improvements
- Report encountered stderr/stdout when none is expected - Fix processing testcases where the code to run is defined first - Set module search path to source tree to enable loading C extensions Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'run_tests.sh')
-rwxr-xr-xrun_tests.sh15
1 files changed, 8 insertions, 7 deletions
diff --git a/run_tests.sh b/run_tests.sh
index a22ecec..2d35c81 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -47,22 +47,23 @@ run_testcase() {
local code=$6
local fail=0
- ./ucode -i - <"$in" >"$dir/res.out" 2>"$dir/res.err"
+ ./ucode -e '{ "REQUIRE_SEARCH_PATH": [ "./lib/*.so" ] }' -i - <"$in" >"$dir/res.out" 2>"$dir/res.err"
+ touch "$dir/empty"
printf "%d\n" $? > "$dir/res.code"
- if [ -n "$err" ] && ! cmp -s "$dir/res.err" "$err"; then
+ if ! cmp -s "$dir/res.err" "${err:-$dir/empty}"; then
[ $fail = 0 ] && printf "!\n"
printf "Testcase #%d: Expected stderr did not match:\n" $num
- diff -u --color=always --label="Expected stderr" --label="Resulting stderr" "$err" "$dir/res.err"
+ diff -u --color=always --label="Expected stderr" --label="Resulting stderr" "${err:-$dir/empty}" "$dir/res.err"
printf -- "---\n"
fail=1
fi
- if [ -n "$out" ] && ! cmp -s "$dir/res.out" "$out"; then
+ if ! cmp -s "$dir/res.out" "${out:-$dir/empty}"; then
[ $fail = 0 ] && printf "!\n"
printf "Testcase #%d: Expected stdout did not match:\n" $num
- diff -u --color=always --label="Expected stdout" --label="Resulting stdout" "$out" "$dir/res.out"
+ diff -u --color=always --label="Expected stdout" --label="Resulting stdout" "${out:-$dir/empty}" "$dir/res.out"
printf -- "---\n"
fail=1
fi
@@ -102,12 +103,12 @@ run_test() {
# Flush previous test
if [ -n "$ein" ]; then
run_testcase $count "/tmp/test.$$" "$ein" "$eout" "$eerr" "$ecode" || failed=$((failed + 1))
-
- ein=$res
eout=""
eerr=""
ecode=""
fi
+
+ ein=$res
else
run_testcase $count "/tmp/test.$$" "$res" "$eout" "$eerr" "$ecode" || failed=$((failed + 1))