Sync usage with man page.
[netbsd-mini2440.git] / usr.bin / make / unit-tests / Makefile
blob9b3b15265d40580eb367e368837d31bc6c77ffac
1 # $NetBSD: Makefile,v 1.24 2009/10/07 16:40:30 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 export \
25 export-all \
26 dotwait \
27 forsubst \
28 moderrs \
29 modmatch \
30 modmisc \
31 modorder \
32 modts \
33 modword \
34 posix \
35 qequals \
36 ternary \
37 unexport \
38 unexport-env \
39 varcmd
41 all: ${SUBFILES}
43 # the tests are actually done with sub-makes.
44 .PHONY: ${SUBFILES}
45 .PRECIOUS: ${SUBFILES}
46 ${SUBFILES}:
47 -@${.MAKE} -k -f ${UNIT_TESTS}/$@
49 clean:
50 rm -f *.out *.fail *.core
52 .include <bsd.obj.mk>
54 TEST_MAKE?= ${.MAKE}
56 # The driver.
57 # We always pretend .MAKE was called 'make'
58 # and strip ${.CURDIR}/ from the output
59 # and replace anything after 'stopped in' with unit-tests
60 # so the results can be compared.
61 test:
62 @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
63 @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
64 ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \
65 -e '/stopped/s, /.*, unit-tests,' \
66 -e 's,${.CURDIR:C/\./\\\./g}/,,g' \
67 -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
68 tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
69 diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
71 accept:
72 mv test.out ${.CURDIR}/test.exp