Makefile.in revision 249033
133965Sjdp# $Id: Makefile.in,v 1.42 2013/03/23 02:31:13 sjg Exp $
233965Sjdp#
333965Sjdp# $NetBSD: Makefile,v 1.36 2013/03/22 16:36:46 sjg Exp $
433965Sjdp#
533965Sjdp# Unit tests for make(1)
689857Sobrien# The main targets are:
789857Sobrien# 
833965Sjdp# all:	run all the tests
989857Sobrien# test:	run 'all', capture output and compare to expected results
1089857Sobrien# accept: move generated output to expected results
1189857Sobrien#
1289857Sobrien# Adding a test case.  
1389857Sobrien# Each feature should get its own set of tests in its own suitably
1489857Sobrien# named makefile which should be added to SUBFILES to hook it in.
1533965Sjdp# 
1689857Sobrien
1789857Sobriensrcdir= @srcdir@
1889857Sobrien
1989857Sobrien.MAIN: all
2089857Sobrien
2189857SobrienUNIT_TESTS:= ${srcdir}
2289857Sobrien
2333965Sjdp# Simple sub-makefiles - we run them as a black box
2489857Sobrien# keep the list sorted.
2589857SobrienSUBFILES= \
2633965Sjdp	comment \
2733965Sjdp	cond1 \
2833965Sjdp	error \
2933965Sjdp	export \
3033965Sjdp	export-all \
3133965Sjdp	export-env \
3233965Sjdp	doterror \
3333965Sjdp	dotwait \
3433965Sjdp	forloop \
3533965Sjdp	forsubst \
36218822Sdim	hash \
3733965Sjdp	misc \
3833965Sjdp	moderrs \
3933965Sjdp	modmatch \
4033965Sjdp	modmisc \
4133965Sjdp	modorder \
4233965Sjdp	modts \
4333965Sjdp	modword \
4433965Sjdp	order \
4533965Sjdp	phony-end \
46218822Sdim	posix \
4733965Sjdp	qequals \
4833965Sjdp	sysv \
4933965Sjdp	ternary \
5033965Sjdp	unexport \
51	unexport-env \
52	varcmd
53
54all: ${SUBFILES}
55
56flags.doterror=
57flags.order=-j1
58
59# the tests are actually done with sub-makes.
60.PHONY: ${SUBFILES}
61.PRECIOUS: ${SUBFILES}
62${SUBFILES}:
63	-@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@
64
65clean:
66	rm -f *.out *.fail *.core
67
68.-include <obj.mk>
69
70TEST_MAKE?= ${.MAKE}
71TOOL_SED?= sed
72TOOL_TR?= tr
73TOOL_DIFF?= diff
74DIFF_FLAGS?= @diff_u@
75
76.if defined(.PARSEDIR)
77# ensure consistent results from sort(1)
78LC_ALL= C
79LANG= C
80.export LANG LC_ALL
81.endif
82
83# The driver.
84# We always pretend .MAKE was called 'make' 
85# and strip ${.CURDIR}/ from the output
86# and replace anything after 'stopped in' with unit-tests
87# so the results can be compared.
88test:
89	@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
90	@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
91	${TOOL_TR} -d '\015' | \
92	${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \
93	-e '/stopped/s, /.*, unit-tests,' \
94	-e 's,${.CURDIR:C/\./\\\./g}/,,g' \
95	-e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
96	tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
97	${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
98
99accept:
100	mv test.out ${srcdir}/test.exp
101
102