100% coverage of cheat.c
[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 check: regress
12         @echo "=== No diff output is good news."
13         @-advent -x 2>/dev/null # Get usage message into coverage tests
14         @-advent -l /dev/null <quit.log >/dev/null
15
16 .SUFFIXES: .chk
17
18 clean:
19         rm -fr *~ adventure.text *.adv scratch.tmp
20
21 # Show summary lines for all tests.
22 testlist:
23         @grep '^##' *.log
24 listcheck:
25         @for f in *.log; do \
26             if ( head -3 $$f | grep -q '^ *##' ); then :; else echo "$$f needs a description"; fi; \
27         done
28
29 # General regression testing of commands and output; look at the *.log and
30 # corresponding *.chk files to see which tests this runs.
31 TESTLOADS := $(shell ls -1 *.log | sed '/.log/s///' | sort)
32 buildregress:
33         @for file in $(TESTLOADS); do \
34             echo "Remaking $${file}.chk"; \
35             OPTS=`sed -n /#options:/s///p <$${file}.log`; \
36             advent $$OPTS <$${file}.log >$${file}.chk 2>&1 || exit 1; \
37         done; \
38         rm -f scratch.tmp
39 regress:
40         $(ECHO) -n "Generate save file with -1000 deaths: "
41         ../cheat -d -1000 -o cheat_numdie.adv
42         $(ECHO) -n "Generate save file with version -1337: "
43         ../cheat -v -1337 -o resume_badversion.adv
44         $(ECHO) -n "Generate save file 1000 saves: "
45         ../cheat -s -1000 -o thousand_saves.adv
46         $(ECHO) -n "Bogus option for save file generation: "
47         ../cheat -QqQ | true
48         $(ECHO) -n "Fail to save because we omit -o: "
49         ../cheat -d 1 | true
50         $(ECHO) -n "Fail to save to invalid path: "
51         ../cheat -o /badfilename.adv | true
52         @for file in $(TESTLOADS); do \
53             $(ECHO) -n "  $${file} "; grep '##' $${file}.log  || echo ' ## (no description)'; \
54             OPTS=`sed -n /#options:/s///p <$${file}.log`; \
55             if advent $$OPTS < $${file}.log >/tmp/regress$$$$ 2>&1; \
56             then diff --text -u $${file}.chk /tmp/regress$$$$ || exit 1; \
57             else echo "*** Nonzero return status on $${file}!"; exit 1; fi \
58         done; \
59         rm -f scratch.tmp /tmp/regress$$$$
60
61 # end