More Makefile simplification.
[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 all: regress
15         @echo "=== No diff output is good news."
16
17 .SUFFIXES: .chk
18
19 clean:
20         rm -fr *~ adventure.text adventure.data
21
22 # Show summary lines for all tests.
23 testlist:
24         @grep --text '^##' *.log
25 listcheck:
26         @for f in *.log; do \
27             if ( head -3 $$f | grep --text -q '^ *##' ); then :; else echo "$$f needs a description"; fi; \
28         done
29
30 # General regression testing of commands and output; look at the *.log and
31 # corresponding *.chk files to see which tests this runs.
32 TESTLOADS := $(shell ls -1 *.log | sed '/.log/s///')
33 buildregress: adventure.data
34         @for file in $(TESTLOADS); do \
35             echo "Remaking $${file}.chk"; \
36             advent <$${file}.log >$${file}.chk 2>&1 || exit 1; \
37         done
38 regress: adventure.data
39         @for file in $(TESTLOADS); do \
40             $(ECHO) -n "  $${file} "; grep --text '##' $${file}.log  || echo ' ## (no description)'; \
41             if advent < $${file}.log >/tmp/regress$$$$ 2>&1; \
42             then diff --text -u $${file}.chk /tmp/regress$$$$ || exit 1; \
43             else echo "*** Nonzero return status on $${file}!"; exit 1; fi \
44         done
45         @rm -f /tmp/regress$$$$
46
47 adventure.data: 
48         cp "$(realpath ..)"/adventure.text .
49         timeout 1 advent >/dev/null 2>&1; true
50
51 # end