1 # $NetBSD: Makefile,v 1.38 2013/08/28 21:56:50 sjg Exp $
3 # Unit tests for make(1)
4 # The main targets are:
6 # all: run all the tests
7 # test: run 'all', capture output and compare to expected results
8 # accept: move generated output to expected results
11 # Each feature should get its own set of tests in its own suitably
12 # named makefile which should be added to SUBFILES to hook it in.
17 UNIT_TESTS
:= ${.PARSEDIR
}
19 # Simple sub-makefiles - we run them as a black box
20 # keep the list sorted.
56 # the tests are actually done with sub-makes.
58 .PRECIOUS
: ${SUBFILES}
60 -@
${.MAKE
} ${flags.
$@
:U-k
} -f
${UNIT_TESTS}/$@
63 rm -f
*.out
*.fail
*.core
65 .
-include <bsd.obj.mk
>
70 # ensure consistent results from sort(1)
76 # We always pretend .MAKE was called 'make'
77 # and strip ${.CURDIR}/ from the output
78 # and replace anything after 'stopped in' with unit-tests
79 # so the results can be compared.
81 @echo
"${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
82 @cd
${.OBJDIR
} && ${TEST_MAKE} -f
${MAKEFILE} 2>&1 | \
83 ${TOOL_SED} -e
's,^${TEST_MAKE:T:C/\./\\\./g}[^:]*:,make:,' \
84 -e
'/stopped/s, /.*, unit-tests,' \
85 -e
's,${.CURDIR:C/\./\\\./g}/,,g' \
86 -e
's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET
}.out ||
{ \
87 tail
${.TARGET
}.out
; mv
${.TARGET
}.out
${.TARGET
}.fail
; exit
1; }
88 diff
-u
${UNIT_TESTS}/${.TARGET
}.exp
${.TARGET
}.out
91 mv
test.out
${.CURDIR
}/test.exp