1241279Smarcel# This is a generated file, do NOT edit!
2241279Smarcel# See contrib/bmake/bsd.after-import.mk
3241279Smarcel#
4241279Smarcel# $FreeBSD$
5241279Smarcel
6241279SmarcelSRCTOP?= ${.CURDIR:H:H:H}
7241279Smarcel
8255253Ssjg# $Id: Makefile.in,v 1.44 2013/08/28 22:09:29 sjg Exp $
9241279Smarcel#
10255253Ssjg# $NetBSD: Makefile,v 1.38 2013/08/28 21:56:50 sjg Exp $
11241279Smarcel#
12241279Smarcel# Unit tests for make(1)
13241279Smarcel# The main targets are:
14241279Smarcel# 
15241279Smarcel# all:	run all the tests
16241279Smarcel# test:	run 'all', capture output and compare to expected results
17241279Smarcel# accept: move generated output to expected results
18241279Smarcel#
19241279Smarcel# Adding a test case.  
20241279Smarcel# Each feature should get its own set of tests in its own suitably
21241279Smarcel# named makefile which should be added to SUBFILES to hook it in.
22241279Smarcel# 
23241279Smarcel
24241279Smarcelsrcdir= ${SRCTOP}/contrib/bmake/unit-tests
25241279Smarcel
26241279Smarcel.MAIN: all
27241279Smarcel
28241279SmarcelUNIT_TESTS:= ${srcdir}
29241279Smarcel
30241279Smarcel# Simple sub-makefiles - we run them as a black box
31241279Smarcel# keep the list sorted.
32241279SmarcelSUBFILES= \
33241279Smarcel	comment \
34241279Smarcel	cond1 \
35241279Smarcel	error \
36241279Smarcel	export \
37241279Smarcel	export-all \
38249033Ssjg	export-env \
39241279Smarcel	doterror \
40241279Smarcel	dotwait \
41241279Smarcel	forloop \
42241279Smarcel	forsubst \
43241279Smarcel	hash \
44241279Smarcel	misc \
45241279Smarcel	moderrs \
46241279Smarcel	modmatch \
47241279Smarcel	modmisc \
48241279Smarcel	modorder \
49241279Smarcel	modts \
50241279Smarcel	modword \
51243115Ssjg	order \
52241279Smarcel	phony-end \
53241279Smarcel	posix \
54241279Smarcel	qequals \
55255253Ssjg	sunshcmd \
56241279Smarcel	sysv \
57241279Smarcel	ternary \
58241279Smarcel	unexport \
59241279Smarcel	unexport-env \
60241279Smarcel	varcmd
61241279Smarcel
62241279Smarcelall: ${SUBFILES}
63241279Smarcel
64241279Smarcelflags.doterror=
65243115Ssjgflags.order=-j1
66241279Smarcel
67241279Smarcel# the tests are actually done with sub-makes.
68241279Smarcel.PHONY: ${SUBFILES}
69241279Smarcel.PRECIOUS: ${SUBFILES}
70241279Smarcel${SUBFILES}:
71241279Smarcel	-@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@
72241279Smarcel
73241279Smarcelclean:
74241279Smarcel	rm -f *.out *.fail *.core
75241279Smarcel
76241279Smarcel.sinclude <bsd.obj.mk>
77241279Smarcel
78241279SmarcelTEST_MAKE?= ${.MAKE}
79241279SmarcelTOOL_SED?= sed
80241279SmarcelTOOL_TR?= tr
81241279SmarcelTOOL_DIFF?= diff
82241279SmarcelDIFF_FLAGS?= -u
83241279Smarcel
84246325Ssjg.if defined(.PARSEDIR)
85241279Smarcel# ensure consistent results from sort(1)
86241279SmarcelLC_ALL= C
87241279SmarcelLANG= C
88241279Smarcel.export LANG LC_ALL
89246325Ssjg.endif
90241279Smarcel
91241279Smarcel# The driver.
92241279Smarcel# We always pretend .MAKE was called 'make' 
93241279Smarcel# and strip ${.CURDIR}/ from the output
94241279Smarcel# and replace anything after 'stopped in' with unit-tests
95241279Smarcel# so the results can be compared.
96241279Smarceltest:
97241279Smarcel	@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
98241279Smarcel	@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
99241279Smarcel	${TOOL_TR} -d '\015' | \
100253883Ssjg	${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[^:]*:,make:,' \
101241279Smarcel	-e '/stopped/s, /.*, unit-tests,' \
102241279Smarcel	-e 's,${.CURDIR:C/\./\\\./g}/,,g' \
103241279Smarcel	-e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
104241279Smarcel	tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
105241279Smarcel	${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
106241279Smarcel
107241279Smarcelaccept:
108241279Smarcel	mv test.out ${srcdir}/test.exp
109241279Smarcel
110