1d4d90f10SMarcel Moolenaar# This is a generated file, do NOT edit!
2d4d90f10SMarcel Moolenaar# See contrib/bmake/bsd.after-import.mk
3d4d90f10SMarcel Moolenaar#
4d4d90f10SMarcel Moolenaar# $FreeBSD$
5d4d90f10SMarcel Moolenaar
6d4d90f10SMarcel MoolenaarSRCTOP?= ${.CURDIR:H:H:H}
7d4d90f10SMarcel Moolenaar
83cbdda60SSimon J. Gerraty# $Id: Makefile.in,v 1.48 2015/12/07 04:06:29 sjg Exp $
9d4d90f10SMarcel Moolenaar#
1059a02420SSimon J. Gerraty# $NetBSD: Makefile,v 1.52 2015/05/05 21:51:09 sjg Exp $
11d4d90f10SMarcel Moolenaar#
12d4d90f10SMarcel Moolenaar# Unit tests for make(1)
13d4d90f10SMarcel Moolenaar# The main targets are:
14d4d90f10SMarcel Moolenaar#
15d4d90f10SMarcel Moolenaar# all:	run all the tests
16d4d90f10SMarcel Moolenaar# test:	run 'all', and compare to expected results
17d4d90f10SMarcel Moolenaar# accept: move generated output to expected results
18d4d90f10SMarcel Moolenaar#
19d4d90f10SMarcel Moolenaar# Adding a test case.
20d4d90f10SMarcel Moolenaar# Each feature should get its own set of tests in its own suitably
21d4d90f10SMarcel Moolenaar# named makefile (*.mk), with its own set of expected results (*.exp),
22d4d90f10SMarcel Moolenaar# and it should be added to the TESTNAMES list.
23d4d90f10SMarcel Moolenaar#
24d4d90f10SMarcel Moolenaar
25d4d90f10SMarcel Moolenaarsrcdir= ${SRCTOP}/contrib/bmake/unit-tests
26d4d90f10SMarcel Moolenaar
27d4d90f10SMarcel Moolenaar.MAIN: all
28d4d90f10SMarcel Moolenaar
29d4d90f10SMarcel MoolenaarUNIT_TESTS:= ${srcdir}
30d4d90f10SMarcel Moolenaar.PATH: ${UNIT_TESTS}
31d4d90f10SMarcel Moolenaar
32d4d90f10SMarcel Moolenaar# Each test is in a sub-makefile.
33d4d90f10SMarcel Moolenaar# Keep the list sorted.
34d4d90f10SMarcel MoolenaarTESTNAMES= \
35d4d90f10SMarcel Moolenaar	comment \
36d4d90f10SMarcel Moolenaar	cond1 \
37d4d90f10SMarcel Moolenaar	cond2 \
38d4d90f10SMarcel Moolenaar	error \
39d4d90f10SMarcel Moolenaar	export \
40d4d90f10SMarcel Moolenaar	export-all \
41d4d90f10SMarcel Moolenaar	export-env \
42d4d90f10SMarcel Moolenaar	doterror \
43d4d90f10SMarcel Moolenaar	dotwait \
44d4d90f10SMarcel Moolenaar	forloop \
45d4d90f10SMarcel Moolenaar	forsubst \
46d4d90f10SMarcel Moolenaar	hash \
47d4d90f10SMarcel Moolenaar	misc \
48d4d90f10SMarcel Moolenaar	moderrs \
49d4d90f10SMarcel Moolenaar	modmatch \
5059a02420SSimon J. Gerraty	modmisc \
51d4d90f10SMarcel Moolenaar	modorder \
52d4d90f10SMarcel Moolenaar	modts \
53d4d90f10SMarcel Moolenaar	modword \
54d4d90f10SMarcel Moolenaar	order \
55d4d90f10SMarcel Moolenaar	posix \
56d4d90f10SMarcel Moolenaar	qequals \
57d4d90f10SMarcel Moolenaar	sunshcmd \
58d4d90f10SMarcel Moolenaar	sysv \
59d4d90f10SMarcel Moolenaar	ternary \
60d4d90f10SMarcel Moolenaar	unexport \
61d4d90f10SMarcel Moolenaar	unexport-env \
62d4d90f10SMarcel Moolenaar	varcmd \
6359a02420SSimon J. Gerraty	varmisc \
64d4d90f10SMarcel Moolenaar	varshell
65d4d90f10SMarcel Moolenaar
66d4d90f10SMarcel Moolenaar# these tests were broken by referting POSIX chanegs
67d4d90f10SMarcel MoolenaarSTRICT_POSIX_TESTS = \
68d4d90f10SMarcel Moolenaar	escape \
69d4d90f10SMarcel Moolenaar	impsrc \
70d4d90f10SMarcel Moolenaar	phony-end \
71d4d90f10SMarcel Moolenaar	posix1 \
72d4d90f10SMarcel Moolenaar	suffixes
73d4d90f10SMarcel Moolenaar
74d4d90f10SMarcel Moolenaar# Override make flags for certain tests
75d4d90f10SMarcel Moolenaarflags.doterror=
76d4d90f10SMarcel Moolenaarflags.order=-j1
77d4d90f10SMarcel Moolenaar
78d4d90f10SMarcel MoolenaarOUTFILES= ${TESTNAMES:S/$/.out/}
79d4d90f10SMarcel Moolenaar
80d4d90f10SMarcel Moolenaarall: ${OUTFILES}
81d4d90f10SMarcel Moolenaar
82*4639b858SSimon J. GerratyCLEANFILES += *.rawout *.out *.status *.tmp *.core *.tmp
83d4d90f10SMarcel MoolenaarCLEANFILES += obj*.[och] lib*.a		# posix1.mk
84d4d90f10SMarcel MoolenaarCLEANFILES += issue* .[ab]*		# suffixes.mk
85d4d90f10SMarcel MoolenaarCLEANRECURSIVE += dir dummy		# posix1.mk
86d4d90f10SMarcel Moolenaar
87*4639b858SSimon J. Gerratyclean:
88d4d90f10SMarcel Moolenaar	rm -f ${CLEANFILES}
89d4d90f10SMarcel Moolenaar.if !empty(CLEANRECURSIVE)
90d4d90f10SMarcel Moolenaar	rm -rf ${CLEANRECURSIVE}
91d4d90f10SMarcel Moolenaar.endif
92d4d90f10SMarcel Moolenaar
93d4d90f10SMarcel MoolenaarTEST_MAKE?= ${.MAKE}
94d4d90f10SMarcel MoolenaarTOOL_SED?= sed
95d4d90f10SMarcel MoolenaarTOOL_TR?= tr
96d4d90f10SMarcel MoolenaarTOOL_DIFF?= diff
97d4d90f10SMarcel MoolenaarDIFF_FLAGS?= -u
98d4d90f10SMarcel Moolenaar
99d4d90f10SMarcel Moolenaar.if defined(.PARSEDIR)
100d4d90f10SMarcel Moolenaar# ensure consistent results from sort(1)
101d4d90f10SMarcel MoolenaarLC_ALL= C
102d4d90f10SMarcel MoolenaarLANG= C
103d4d90f10SMarcel Moolenaar.export LANG LC_ALL
104d4d90f10SMarcel Moolenaar.endif
105d4d90f10SMarcel Moolenaar
106d4d90f10SMarcel Moolenaar# some tests need extra post-processing
107d4d90f10SMarcel MoolenaarSED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \
108	-e '/command/s,No such.*,not found,'
109
110# the tests are actually done with sub-makes.
111.SUFFIXES: .mk .rawout .out
112.mk.rawout:
113	@echo ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC}
114	-@cd ${.OBJDIR} && \
115	{ ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} \
116	  2>&1 ; echo $$? >${.TARGET:R}.status ; } > ${.TARGET}.tmp
117	@mv ${.TARGET}.tmp ${.TARGET}
118
119# We always pretend .MAKE was called 'make'
120# and strip ${.CURDIR}/ from the output
121# and replace anything after 'stopped in' with unit-tests
122# so the results can be compared.
123.rawout.out:
124	@echo postprocess ${.TARGET}
125	@${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[][0-9]*:,make:,' \
126	  -e 's,${TEST_MAKE:C/\./\\\./g},make,' \
127	  -e '/stopped/s, /.*, unit-tests,' \
128	  -e 's,${.CURDIR:C/\./\\\./g}/,,g' \
129	  -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' ${SED_CMDS.${.TARGET:T:R}} \
130	  < ${.IMPSRC} > ${.TARGET}.tmp
131	@echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp
132	@mv ${.TARGET}.tmp ${.TARGET}
133
134# Compare all output files
135test:	${OUTFILES} .PHONY
136	@failed= ; \
137	for test in ${TESTNAMES}; do \
138	  ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \
139	  || failed="$${failed}$${failed:+ }$${test}" ; \
140	done ; \
141	if [ -n "$${failed}" ]; then \
142	  echo "Failed tests: $${failed}" ; false ; \
143	else \
144	  echo "All tests passed" ; \
145	fi
146
147accept:
148	@for test in ${TESTNAMES}; do \
149	  cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
150	  || { echo "Replacing $${test}.exp" ; \
151	       cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
152	done
153
154.if exists(${TEST_MAKE})
155${TESTNAMES:S/$/.rawout/}: ${TEST_MAKE}
156.endif
157
158.sinclude <bsd.obj.mk>
159