aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2020-03-09 00:37:34 -0700
committerMichael Forney <mforney@mforney.org>2020-03-16 02:21:13 -0700
commitfd836460ae1f1879bd27cff2e4a60d29ab24de43 (patch)
treea53c717a7cb396f2be7883aa5d17831cda9e710f
parent494420db4966e36d8550a86f4252ab4a888369c1 (diff)
runtests: Add support for preprocessor tests
-rwxr-xr-xruntests20
1 files changed, 17 insertions, 3 deletions
diff --git a/runtests b/runtests
index 4b92de6..3c05631 100755
--- a/runtests
+++ b/runtests
@@ -1,14 +1,28 @@
#!/bin/sh
+: ${CCQBE:=./cproc-qbe}
+
if [ $# = 0 ] ; then
set -- test/*.c
fi
numfail=0
-out=$(mktemp)
-trap 'rm "$out"' EXIT
+got=$(mktemp)
+trap 'rm "$got"' EXIT
+
for test ; do
- if ${CCQBE:=./cproc-qbe} -o $out $test && diff -Nu "${test%.c}.qbe" "$out" ; then
+ name=${test%.c}
+ if [ -f "$name.qbe" ] ; then
+ want=$name.qbe
+ set -- $CCQBE -o "$got" "$test"
+ elif [ -f "$name.pp" ] ; then
+ want=$name.pp
+ set -- $CCQBE -E -o "$got" "$test"
+ else
+ echo "invalid test '$test'" >&2
+ set -- false
+ fi
+ if "$@" && diff -Nu "$want" "$got" ; then
result="PASS"
else
result="FAIL"