1 # $Id: Makefile.in,v 1.44 2013/08/28 22:09:29 sjg Exp $
3 # $NetBSD: Makefile,v 1.38 2013/08/28 21:56:50 sjg Exp $
5 # Unit tests for make(1)
6 # The main targets are:
8 # all: run all the tests
9 # test: run 'all', capture output and compare to expected results
10 # accept: move generated output to expected results
13 # Each feature should get its own set of tests in its own suitably
14 # named makefile which should be added to SUBFILES to hook it in.
21 UNIT_TESTS:= ${srcdir}
23 # Simple sub-makefiles - we run them as a black box
24 # keep the list sorted.
60 # the tests are actually done with sub-makes.
62 .PRECIOUS: ${SUBFILES}
64 -@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@
67 rm -f *.out *.fail *.core
77 .if defined(.PARSEDIR)
78 # ensure consistent results from sort(1)
85 # We always pretend .MAKE was called 'make'
86 # and strip ${.CURDIR}/ from the output
87 # and replace anything after 'stopped in' with unit-tests
88 # so the results can be compared.
90 @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
91 @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
92 ${TOOL_TR} -d '\015' | \
93 ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[^:]*:,make:,' \
94 -e '/stopped/s, /.*, unit-tests,' \
95 -e 's,${.CURDIR:C/\./\\\./g}/,,g' \
96 -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
97 tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
98 ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
101 mv test.out ${srcdir}/test.exp