Makefile revision 246325
1241279Smarcel# This is a generated file, do NOT edit!
2241279Smarcel# See contrib/bmake/bsd.after-import.mk
3241279Smarcel#
4241279Smarcel# $FreeBSD: head/usr.bin/bmake/unit-tests/Makefile 246325 2013-02-04 17:41:17Z sjg $
5241279Smarcel
6241279SmarcelSRCTOP?= ${.CURDIR:H:H:H}
7241279Smarcel
8246223Ssjg# $Id: Makefile.in,v 1.40 2012/12/28 21:28:19 sjg Exp $
9241279Smarcel#
10243115Ssjg# $NetBSD: Makefile,v 1.35 2012/11/09 19:08:28 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 \
38241279Smarcel	doterror \
39241279Smarcel	dotwait \
40241279Smarcel	forloop \
41241279Smarcel	forsubst \
42241279Smarcel	hash \
43241279Smarcel	misc \
44241279Smarcel	moderrs \
45241279Smarcel	modmatch \
46241279Smarcel	modmisc \
47241279Smarcel	modorder \
48241279Smarcel	modts \
49241279Smarcel	modword \
50243115Ssjg	order \
51241279Smarcel	phony-end \
52241279Smarcel	posix \
53241279Smarcel	qequals \
54241279Smarcel	sysv \
55241279Smarcel	ternary \
56241279Smarcel	unexport \
57241279Smarcel	unexport-env \
58241279Smarcel	varcmd
59241279Smarcel
60241279Smarcelall: ${SUBFILES}
61241279Smarcel
62241279Smarcelflags.doterror=
63243115Ssjgflags.order=-j1
64241279Smarcel
65241279Smarcel# the tests are actually done with sub-makes.
66241279Smarcel.PHONY: ${SUBFILES}
67241279Smarcel.PRECIOUS: ${SUBFILES}
68241279Smarcel${SUBFILES}:
69241279Smarcel	-@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@
70241279Smarcel
71241279Smarcelclean:
72241279Smarcel	rm -f *.out *.fail *.core
73241279Smarcel
74241279Smarcel.sinclude <bsd.obj.mk>
75241279Smarcel
76241279SmarcelTEST_MAKE?= ${.MAKE}
77241279SmarcelTOOL_SED?= sed
78241279SmarcelTOOL_TR?= tr
79241279SmarcelTOOL_DIFF?= diff
80241279SmarcelDIFF_FLAGS?= -u
81241279Smarcel
82246325Ssjg.if defined(.PARSEDIR)
83241279Smarcel# ensure consistent results from sort(1)
84241279SmarcelLC_ALL= C
85241279SmarcelLANG= C
86241279Smarcel.export LANG LC_ALL
87246325Ssjg.endif
88241279Smarcel
89241279Smarcel# The driver.
90241279Smarcel# We always pretend .MAKE was called 'make' 
91241279Smarcel# and strip ${.CURDIR}/ from the output
92241279Smarcel# and replace anything after 'stopped in' with unit-tests
93241279Smarcel# so the results can be compared.
94241279Smarceltest:
95241279Smarcel	@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
96241279Smarcel	@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
97241279Smarcel	${TOOL_TR} -d '\015' | \
98241279Smarcel	${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \
99241279Smarcel	-e '/stopped/s, /.*, unit-tests,' \
100241279Smarcel	-e 's,${.CURDIR:C/\./\\\./g}/,,g' \
101241279Smarcel	-e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
102241279Smarcel	tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
103241279Smarcel	${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
104241279Smarcel
105241279Smarcelaccept:
106241279Smarcel	mv test.out ${srcdir}/test.exp
107241279Smarcel
108