Makefile.in revision 243115
1243115Ssjg# $Id: Makefile.in,v 1.39 2012/11/09 19:16:10 sjg Exp $
2236769Sobrien#
3243115Ssjg# $NetBSD: Makefile,v 1.35 2012/11/09 19:08:28 sjg Exp $
4236769Sobrien#
5236769Sobrien# Unit tests for make(1)
6236769Sobrien# The main targets are:
7236769Sobrien# 
8236769Sobrien# all:	run all the tests
9236769Sobrien# test:	run 'all', capture output and compare to expected results
10236769Sobrien# accept: move generated output to expected results
11236769Sobrien#
12236769Sobrien# Adding a test case.  
13236769Sobrien# Each feature should get its own set of tests in its own suitably
14236769Sobrien# named makefile which should be added to SUBFILES to hook it in.
15236769Sobrien# 
16236769Sobrien
17236769Sobriensrcdir= @srcdir@
18236769Sobrien
19236769Sobrien.MAIN: all
20236769Sobrien
21236769SobrienUNIT_TESTS:= ${srcdir}
22236769Sobrien
23236769Sobrien# Simple sub-makefiles - we run them as a black box
24236769Sobrien# keep the list sorted.
25236769SobrienSUBFILES= \
26236769Sobrien	comment \
27236769Sobrien	cond1 \
28236769Sobrien	error \
29236769Sobrien	export \
30236769Sobrien	export-all \
31236769Sobrien	doterror \
32236769Sobrien	dotwait \
33237578Sobrien	forloop \
34236769Sobrien	forsubst \
35236769Sobrien	hash \
36236769Sobrien	misc \
37236769Sobrien	moderrs \
38236769Sobrien	modmatch \
39236769Sobrien	modmisc \
40236769Sobrien	modorder \
41236769Sobrien	modts \
42236769Sobrien	modword \
43243115Ssjg	order \
44236769Sobrien	phony-end \
45236769Sobrien	posix \
46236769Sobrien	qequals \
47236769Sobrien	sysv \
48236769Sobrien	ternary \
49236769Sobrien	unexport \
50236769Sobrien	unexport-env \
51236769Sobrien	varcmd
52236769Sobrien
53236769Sobrienall: ${SUBFILES}
54236769Sobrien
55236769Sobrienflags.doterror=
56243115Ssjgflags.order=-j1
57236769Sobrien
58236769Sobrien# the tests are actually done with sub-makes.
59236769Sobrien.PHONY: ${SUBFILES}
60236769Sobrien.PRECIOUS: ${SUBFILES}
61236769Sobrien${SUBFILES}:
62236769Sobrien	-@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@
63236769Sobrien
64236769Sobrienclean:
65236769Sobrien	rm -f *.out *.fail *.core
66236769Sobrien
67236769Sobrien.-include <bsd.obj.mk>
68236769Sobrien
69236769SobrienTEST_MAKE?= ${.MAKE}
70236769SobrienTOOL_SED?= sed
71236769SobrienTOOL_TR?= tr
72236769SobrienTOOL_DIFF?= diff
73236769SobrienDIFF_FLAGS?= @diff_u@
74236769Sobrien
75236769Sobrien# ensure consistent results from sort(1)
76236769SobrienLC_ALL= C
77236769SobrienLANG= C
78236769Sobrien.export LANG LC_ALL
79236769Sobrien
80236769Sobrien# The driver.
81236769Sobrien# We always pretend .MAKE was called 'make' 
82236769Sobrien# and strip ${.CURDIR}/ from the output
83236769Sobrien# and replace anything after 'stopped in' with unit-tests
84236769Sobrien# so the results can be compared.
85236769Sobrientest:
86236769Sobrien	@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
87236769Sobrien	@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
88236769Sobrien	${TOOL_TR} -d '\015' | \
89236769Sobrien	${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \
90236769Sobrien	-e '/stopped/s, /.*, unit-tests,' \
91236769Sobrien	-e 's,${.CURDIR:C/\./\\\./g}/,,g' \
92236769Sobrien	-e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
93236769Sobrien	tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
94236769Sobrien	${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
95236769Sobrien
96236769Sobrienaccept:
97236769Sobrien	mv test.out ${srcdir}/test.exp
98236769Sobrien
99