From fd836460ae1f1879bd27cff2e4a60d29ab24de43 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Mon, 9 Mar 2020 00:37:34 -0700 Subject: runtests: Add support for preprocessor tests --- runtests | 20 +++++++++++++++++--- 1 file 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" -- cgit v1.2.3