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