Makefile revision 1.20
1# $NetBSD: Makefile,v 1.20 2006/05/11 15:37:07 sjg Exp $
2#
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
9#
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.
13# 
14
15.MAIN: all
16
17UNIT_TESTS:= ${.PARSEDIR}
18
19# Simple sub-makefiles - we run them as a black box
20# keep the list sorted.
21SUBFILES= \
22	comment \
23	cond1 \
24	dotwait \
25	moderrs \
26	modmatch \
27	modmisc \
28	modorder \
29	modts \
30	modword \
31	posix \
32	ternary \
33	varcmd
34
35all: ${SUBFILES}
36
37# the tests are actually done with sub-makes.
38.PHONY: ${SUBFILES}
39.PRECIOUS: ${SUBFILES}
40${SUBFILES}:
41	-@${.MAKE} -k -f ${UNIT_TESTS}/$@
42
43clean:
44	rm -f *.out *.fail *.core
45
46.include <bsd.obj.mk>
47
48TEST_MAKE?= ${.MAKE}
49
50# The driver.
51# We always pretend .MAKE was called 'make' 
52# and strip ${.CURDIR}/ from the output
53# and replace anything after 'stopped in' with unit-tests
54# so the results can be compared.
55test:
56	@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
57	@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
58	sed -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \
59	-e '/stopped/s, /.*, unit-tests,' \
60	-e 's,${.CURDIR:C/\./\\\./g}/,,g' \
61	-e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
62	tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
63	diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
64
65accept:
66	mv test.out ${.CURDIR}/test.exp
67
68