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