Simplify the test makefile.
[open-adventure.git] / tests / Makefile
1 # Test-suite makefile for reposurgeon
2
3 # By setting the REPOSURGEON environment variable and using -e
4 # a different implementation can be plugged in to the tests.
5
6 # Use absolute path so tests that change working directory still use 
7 # scripts from parent directory.  Note that using $PWD seems to fail
8 # here under Gitlab's CI environment.
9 PATH := $(realpath ..):$(realpath .):${PATH}
10
11 # Defeat annoying behavior under Mac OS X - builtin echo doesn't do -n
12 ECHO := /bin/echo
13
14 default:
15         make -e --quiet all
16
17 all: listcheck regress
18         @echo "=== No diff output is good news."
19
20 .SUFFIXES: .chk
21
22 clean:
23         rm -fr *~ adventure.text adventure.data
24
25 # Show summary lines for all tests.
26 testlist:
27         @grep --text '^##' *.log
28 listcheck:
29         @for f in *.log; do \
30             if ( head -3 $$f | grep --text -q '^ *##' ); then :; else echo "$$f needs a description"; fi; \
31         done
32
33 # General regression testing of commands and output; look at the *.log and
34 # corresponding *.chk files to see which tests this runs.
35 TESTLOADS := $(shell ls -1 *.log | sed '/.log/s///')
36 buildregress: adventure.data
37         @for file in $(TESTLOADS); do \
38             echo "Remaking $${file}.chk"; \
39             advent <$${file}.log >$${file}.chk 2>&1 || exit 1; \
40         done
41 regress: adventure.data
42         @for file in $(TESTLOADS); do \
43             $(ECHO) -n "  $${file} "; grep --text '##' $${file}.log  || echo ' ## (no description)'; \
44             if advent < $${file}.log >/tmp/regress$$$$ 2>&1; \
45             then diff --text -u $${file}.chk /tmp/regress$$$$ || exit 1; \
46             else echo "*** Nonzero return status on $${file}!"; exit 1; fi \
47         done
48         @rm -f /tmp/regress$$$$
49
50 adventure.data: 
51         cp "$(realpath ..)"/adventure.text .
52         timeout 1 advent >/dev/null 2>&1; true
53
54 # end