First version of regression tests.
[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 *~
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:
37         @for file in $(TESTLOADS); do \
38             echo "Remaking $${file}.chk"; \
39             $(REPOSURGEON) advent <$${file}.log >$${file}.chk \
40                 2>&1 || exit 1; \
41         done
42 regress:
43         @for file in $(TESTLOADS); do \
44             $(ECHO) -n "  $${file} "; grep --text '##' $${file}.log  || echo ' ## (no description)'; \
45             if advent $${file}.log >/tmp/regress$$$$ 2>&1; \
46             then diff --text -u $${file}.chk /tmp/regress$$$$ || exit 1; \
47             else echo "*** Nonzero return status on $${file}!"; exit 1; fi \
48         done
49         @rm -f /tmp/regress$$$$
50
51 # end