aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-20 09:20:32 +0100
committerlemon <lsof@mailbox.org>2025-12-20 10:31:38 +0100
commita50b09474d0e561637a5be22db12a10a8b3c9ca8 (patch)
tree9c36527682dfd2352c6e72629a46fc64451f3c70 /test
parentf7167c9ec81a0e8cd99f6692fa60ae1d476c9758 (diff)
test/run.sh: shellcheck
Diffstat (limited to 'test')
-rwxr-xr-xtest/run.sh21
1 files changed, 10 insertions, 11 deletions
diff --git a/test/run.sh b/test/run.sh
index 8954ea7..485b0a8 100755
--- a/test/run.sh
+++ b/test/run.sh
@@ -6,42 +6,41 @@ ntest=0
npass=0
x() {
- echo X $@>>log.txt
- $@ 2>> log.txt
+ echo X "$@">>log.txt
+ "$@" 2>> log.txt
}
run() {
- ntest=$(expr $ntest + 1)
+ ntest=$(( ntest + 1 ))
f="$(basename "$1")"
expected=build/"$(echo "$f" | sed -s 's/\.c$/.expected/')"
- echo ---- $f ---- >> log.txt
+ echo ---- "$f" ---- >> log.txt
mkdir -p build/
args=$(awk '/\/\* ARGS:.*$/ {ORS=" ";for (i=3;i<NF;++i)print $i;ORS="\n";print""}' "$f")
cflags=$(awk '/\/\* CFLAGS:.*$/ {ORS=" ";for (i=3;i<NF;++i)print $i;ORS="\n";print""}' "$f")
- awk '/\/\* EXPECT:$/ {x=k=any=1} x && /\*\// {x=0} x {if (!k)print $0;k=0} END{if(x||!any)exit 1;}' "$f" > "$expected"
- if [ $? == 0 ]; then
+ if awk '/\/\* EXPECT:$/ {x=k=any=1} x && /\*\// {x=0} x {if (!k)print $0;k=0} END{if(x||!any)exit 1;}' "$f" > "$expected"; then
obj=build/"$(echo "$f" | sed -s 's/\.c$/.o/')"
exe=build/"$(echo "$f" | sed -s 's/\.c$//')"
if ! ( x $ANTCC $cflags "$f" -c -o "$obj" && x $ANTCC $cflags "$obj" -o "$exe" ); then
- echo !TEST ERROR $f
+ echo !TEST ERROR "$f"
echo !FAILED TO COMPILE
echo '-------'
else
actual=build/"$(echo "$f" | sed -s 's/\.c$/.actual/')"
x "$exe" $args > "$actual"
if [ "$(md5sum < "$actual")" != "$(md5sum < "$expected")" ]; then
- echo --- !TEST ERROR $f
+ echo --- !TEST ERROR "$f"
diff --unified=0 --color=auto "$expected" "$actual"
echo '-------'
else
- npass=$(expr $npass + 1)
+ npass=$(( npass + 1 ))
fi
fi
else
- echo --- !ignore $f
+ echo --- !ignore "$f"
fi
}
-< /dev/null > log.txt
+: < /dev/null > log.txt
tests=$(find . -regex '\./[0-9]+-.*\.c' | sort)
for test in $tests; do
run $test