t40c term[] count fix
[minix.git] / usr.bin / make / unit-tests / Makefile
blobbf4623f5b225f7e19f39ae951c6120094331fec0
1 # $NetBSD: Makefile,v 1.34 2012/06/19 23:25:53 sjg Exp $
3 # Unit tests for make(1)
4 # The main targets are:
5 #
6 # all: run all the tests
7 # test: run 'all', capture output and compare to expected results
8 # accept: move generated output to expected results
10 # Adding a test case.
11 # Each feature should get its own set of tests in its own suitably
12 # named makefile which should be added to SUBFILES to hook it in.
15 .MAIN: all
17 UNIT_TESTS:= ${.PARSEDIR}
19 # Simple sub-makefiles - we run them as a black box
20 # keep the list sorted.
21 SUBFILES= \
22 comment \
23 cond1 \
24 error \
25 export \
26 export-all \
27 doterror \
28 dotwait \
29 forloop \
30 forsubst \
31 hash \
32 misc \
33 moderrs \
34 modmatch \
35 modmisc \
36 modorder \
37 modts \
38 modword \
39 phony-end \
40 posix \
41 qequals \
42 sysv \
43 ternary \
44 unexport \
45 unexport-env \
46 varcmd
48 all: ${SUBFILES}
50 flags.doterror=
52 # the tests are actually done with sub-makes.
53 .PHONY: ${SUBFILES}
54 .PRECIOUS: ${SUBFILES}
55 ${SUBFILES}:
56 -@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@
58 clean:
59 rm -f *.out *.fail *.core
61 .-include <bsd.obj.mk>
63 TEST_MAKE?= ${.MAKE}
64 TOOL_SED?= sed
66 # ensure consistent results from sort(1)
67 LC_ALL= C
68 LANG= C
69 .export LANG LC_ALL
71 # The driver.
72 # We always pretend .MAKE was called 'make'
73 # and strip ${.CURDIR}/ from the output
74 # and replace anything after 'stopped in' with unit-tests
75 # so the results can be compared.
76 test:
77 @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
78 @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
79 ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \
80 -e '/stopped/s, /.*, unit-tests,' \
81 -e 's,${.CURDIR:C/\./\\\./g}/,,g' \
82 -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
83 tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
84 diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
86 accept:
87 mv test.out ${.CURDIR}/test.exp