1 # Test-suite makefile for reposurgeon
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}
9 # Make this overrideable so it's easier to test old versions
12 # Defeat annoying behavior under Mac OS X - builtin echo doesn't do -n
15 # Find all *.log entries to test
16 TESTLOADS := $(shell ls -1 *.log | sed '/.log/s///' | sort)
18 .PHONY: check coverage clean testlist listcheck savegames buildregress
19 .PHONY: savecheck regress
21 check: savecheck regress
22 @echo "=== No diff output is good news."
23 @-advent -x 2>/dev/null # Get usage message into coverage tests
24 @-advent -l /dev/null <pitfall.log >/dev/null
27 lcov -t "advent" -o ../advent.info -c -d .. --gcov-tool=$(GCOV)
28 genhtml -o ../coverage/ ../advent.info
33 rm -fr *~ adventure.text *.adv scratch.tmp
35 # Show summary lines for all tests.
40 if ( head -3 $$f | grep -q '^ *##' ); then :; else echo "$$f needs a description"; fi; \
43 # Generate bogus savegames.
45 @$(ECHO) "cheat: Generate save file with -1000 deaths"
46 @../cheat -d -1000 -o cheat_numdie.adv > /tmp/cheat_numdie
47 @$(ECHO) "cheat: Generate save file with version -1337"
48 @../cheat -v -1337 -o resume_badversion.adv > /tmp/cheat_badversion
49 @$(ECHO) "cheat: Generate save file 1000 saves"
50 @../cheat -s -1000 -o thousand_saves.adv > /tmp/cheat_1000saves
51 @$(ECHO) "cheat: Generate save file 1000 turns"
52 @../cheat -t -1000 -o thousand_saves.adv > /tmp/cheat_1000turns
53 @$(ECHO) "cheat: Generate save file 1000 turns"
54 @../cheat -l -1000 -o thousand_lamp.adv > /tmp/cheat_1000lamp
58 # Rebuild characterizing tests
59 buildregress: savegames
60 ../cheat -s -1000 -o thousand_saves.adv > /tmp/regress1000saves
61 @for file in $(TESTLOADS); do \
62 echo "Remaking $${file}.chk"; \
63 OPTS=`sed -n /#options:/s///p <$${file}.log`; \
64 advent $$OPTS <$${file}.log >$${file}.chk 2>&1 || exit 1; \
69 @$(ECHO) "TEST cheat: Bogus option for save file generation"
70 @../cheat -QqQ 2> /tmp/coverage_cheat_batopt | true
71 @$(ECHO) "TEST cheat: No save file specified"
72 @../cheat 2>/dev/null | true
73 @$(ECHO) "TEST cheat: Fail to save because we omit -o"
74 @../cheat -d 1 2> /tmp/coverage_cheat_nooutput | true
75 @$(ECHO) "TEST cheat: Fail to save to invalid path"
76 @../cheat -o / 2> /tmp/coverage_cheat_badoutput | true
77 @$(ECHO) "TEST advent: Start with invalid file with -r"
78 @advent -r /badfilename < pitfall.log > /tmp/coverage_advent_readfail 2>&1 || exit 1
79 @$(ECHO) "TEST advent: Start with invalid file with -r"
80 @advent -l / < pitfall.log > /tmp/coverage_advent_logfail 2>&1 || exit 1
81 @$(ECHO) "TEST advent: Test -r with valid input"
82 @advent -r thousand_saves.adv < pitfall.log > /tmp/coverage_advent_readfail 2>&1 || exit 1
85 # General regression testing of commands and output; look at the *.log and
86 # corresponding *.chk files to see which tests this runs.
88 @for file in $(TESTLOADS); do \
89 $(ECHO) -n " $${file} "; grep '##' $${file}.log || echo ' ## (no description)'; \
90 OPTS=`sed -n /#options:/s///p <$${file}.log`; \
91 if $(advent) $$OPTS < $${file}.log >/tmp/regress$$$$ 2>&1; \
92 then diff --text -u $${file}.chk /tmp/regress$$$$ || exit 1; \
93 else echo "*** Nonzero return status on $${file}!"; exit 1; fi \
95 rm -f scratch.tmp /tmp/regress$$$$