Mercurial > ~dholland > hg > ag > index.cgi
diff mk/testprog-defs.sh @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mk/testprog-defs.sh Sat Dec 22 17:52:45 2007 -0500 @@ -0,0 +1,57 @@ +#!/bin/sh +# testprog-defs.sh - generate make rules for testprog.mk +# usage: testprog-defs.sh "tests" "diffonly-tests" > rules.mk + +if [ $# != 2 ]; then + echo "$0: usage: $0 'tests' 'diffonly-tests'" 1>&2 + exit 1 +fi + +TESTS="$1" +DIFFONLY="$2" + +( + for T in $TESTS; do + echo 1 "$T" + done + for T in $DIFFONLY; do + echo 0 "$T"; + done +) | awk ' + { + dorun=$1; + file=$2; + if (file ~ "/") { + srcdir = file; + sub("^.*/", "", file); + sub("/[^/]*$", "", srcdir); + srcdir = "$(TOP)/" srcdir; + } + else { + srcdir = "$(SRCDIR)" + } + base=file; + sub("\\.[a-z][0-9]*$", "", base); + out = base ".out"; + err = base ".err"; + diff = base ".diff"; + + printf "run-tests: %s\n", diff; + printf "%s: $(SRCDIR)/good/%s %s\n", diff, out, out; + printf "%s: $(SRCDIR)/good/%s %s\n", diff, err, err; + printf "\t@echo \" [DIFF] %s\"\n", file; + printf "\t@diff -uN $(SRCDIR)/good/%s %s > $@ || true\n", out, out; + printf "\t@diff -uN $(SRCDIR)/good/%s %s >> $@ || true\n", err, err; + printf "\n"; + + if (dorun) { + printf "%s %s: $(SRCDIR)/%s $(RUNPROG)\n", out, err, file; + printf "\t@echo \" [TEST] %s\"\n", file; + printf "\t@($(CROSSRUN) $(RUNPROG) %s/%s;", srcdir, file; + printf " echo Exit $$? 1>&2) \\\n" + printf "\t > %s 2> %s; \\\n", out, err; + printf "\n"; + } + } +' +