cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

runtests (609B)


      1 #!/bin/sh
      2 
      3 : ${CCQBE:=./cproc-qbe}
      4 
      5 if [ $# = 0 ] ; then
      6 	set -- test/*.c
      7 fi
      8 
      9 numfail=0
     10 got=$(mktemp)
     11 trap 'rm "$got"' EXIT
     12 
     13 for test ; do
     14 	name=${test%.c}
     15 	if [ -f "$name.qbe" ] ; then
     16 		want=$name.qbe
     17 		set -- $CCQBE -o "$got" "$test"
     18 	elif [ -f "$name.pp" ] ; then
     19 		want=$name.pp
     20 		set -- $CCQBE -E -o "$got" "$test"
     21 	else
     22 		echo "invalid test '$test'" >&2
     23 		set -- false
     24 	fi
     25 	if "$@" && diff -Nu "$want" "$got" ; then
     26 		result="PASS"
     27 	else
     28 		result="FAIL"
     29 		numfail=$((numfail + 1))
     30 	fi
     31 	echo "[$result] $test" >&2
     32 done
     33 
     34 if [ "$numfail" -gt 0 ] ; then
     35 	printf "%d test(s) failed\n" "$numfail"
     36 	exit 1
     37 fi