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