diff options
author | Michael Forney <mforney@mforney.org> | 2020-03-09 00:37:34 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2020-03-16 02:21:13 -0700 |
commit | fd836460ae1f1879bd27cff2e4a60d29ab24de43 (patch) | |
tree | a53c717a7cb396f2be7883aa5d17831cda9e710f | |
parent | 494420db4966e36d8550a86f4252ab4a888369c1 (diff) |
runtests: Add support for preprocessor tests
-rwxr-xr-x | runtests | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -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" |