1 # This is a generated file, do NOT edit!
2 # See contrib/bmake/bsd.after-import.mk
6 SRCTOP?= ${.CURDIR:H:H:H}
8 # $Id: Makefile.in,v 1.49 2018/09/21 21:39:05 sjg Exp $
10 # $NetBSD: Makefile,v 1.53 2018/05/24 00:25:44 christos Exp $
12 # Unit tests for make(1)
13 # The main targets are:
15 # all: run all the tests
16 # test: run 'all', and compare to expected results
17 # accept: move generated output to expected results
20 # Each feature should get its own set of tests in its own suitably
21 # named makefile (*.mk), with its own set of expected results (*.exp),
22 # and it should be added to the TESTNAMES list.
25 srcdir= ${SRCTOP}/contrib/bmake/unit-tests
29 UNIT_TESTS:= ${srcdir}
32 # Each test is in a sub-makefile.
33 # Keep the list sorted.
67 # these tests were broken by referting POSIX chanegs
68 STRICT_POSIX_TESTS = \
75 # Override make flags for certain tests
79 OUTFILES= ${TESTNAMES:S/$/.out/}
83 CLEANFILES += *.rawout *.out *.status *.tmp *.core *.tmp
84 CLEANFILES += obj*.[och] lib*.a # posix1.mk
85 CLEANFILES += issue* .[ab]* # suffixes.mk
86 CLEANRECURSIVE += dir dummy # posix1.mk
90 .if !empty(CLEANRECURSIVE)
91 rm -rf ${CLEANRECURSIVE}
100 .if defined(.PARSEDIR)
101 # ensure consistent results from sort(1)
107 # some tests need extra post-processing
108 SED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \
109 -e '/command/s,No such.*,not found,'
111 # the tests are actually done with sub-makes.
112 .SUFFIXES: .mk .rawout .out
114 @echo ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC}
116 { ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} \
117 2>&1 ; echo $$? >${.TARGET:R}.status ; } > ${.TARGET}.tmp
118 @mv ${.TARGET}.tmp ${.TARGET}
120 # We always pretend .MAKE was called 'make'
121 # and strip ${.CURDIR}/ from the output
122 # and replace anything after 'stopped in' with unit-tests
123 # so the results can be compared.
125 @echo postprocess ${.TARGET}
126 @${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[][0-9]*:,make:,' \
127 -e 's,${TEST_MAKE:C/\./\\\./g},make,' \
128 -e '/stopped/s, /.*, unit-tests,' \
129 -e 's,${.CURDIR:C/\./\\\./g}/,,g' \
130 -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' ${SED_CMDS.${.TARGET:T:R}} \
131 < ${.IMPSRC} > ${.TARGET}.tmp
132 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp
133 @mv ${.TARGET}.tmp ${.TARGET}
135 # Compare all output files
136 test: ${OUTFILES} .PHONY
138 for test in ${TESTNAMES}; do \
139 ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \
140 || failed="$${failed}$${failed:+ }$${test}" ; \
142 if [ -n "$${failed}" ]; then \
143 echo "Failed tests: $${failed}" ; false ; \
145 echo "All tests passed" ; \
149 @for test in ${TESTNAMES}; do \
150 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
151 || { echo "Replacing $${test}.exp" ; \
152 cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
155 .if exists(${TEST_MAKE})
156 ${TESTNAMES:S/$/.rawout/}: ${TEST_MAKE}
159 .sinclude <bsd.obj.mk>