Makefile.in revision 253883
1# $Id: Makefile.in,v 1.43 2013/07/16 21:14:30 sjg Exp $ 2# 3# $NetBSD: Makefile,v 1.37 2013/07/16 19:59:28 sjg Exp $ 4# 5# Unit tests for make(1) 6# The main targets are: 7# 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 11# 12# Adding a test case. 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. 15# 16 17srcdir= @srcdir@ 18 19.MAIN: all 20 21UNIT_TESTS:= ${srcdir} 22 23# Simple sub-makefiles - we run them as a black box 24# keep the list sorted. 25SUBFILES= \ 26 comment \ 27 cond1 \ 28 error \ 29 export \ 30 export-all \ 31 export-env \ 32 doterror \ 33 dotwait \ 34 forloop \ 35 forsubst \ 36 hash \ 37 misc \ 38 moderrs \ 39 modmatch \ 40 modmisc \ 41 modorder \ 42 modts \ 43 modword \ 44 order \ 45 phony-end \ 46 posix \ 47 qequals \ 48 sysv \ 49 ternary \ 50 unexport \ 51 unexport-env \ 52 varcmd 53 54all: ${SUBFILES} 55 56flags.doterror= 57flags.order=-j1 58 59# the tests are actually done with sub-makes. 60.PHONY: ${SUBFILES} 61.PRECIOUS: ${SUBFILES} 62${SUBFILES}: 63 -@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@ 64 65clean: 66 rm -f *.out *.fail *.core 67 68.-include <obj.mk> 69 70TEST_MAKE?= ${.MAKE} 71TOOL_SED?= sed 72TOOL_TR?= tr 73TOOL_DIFF?= diff 74DIFF_FLAGS?= @diff_u@ 75 76.if defined(.PARSEDIR) 77# ensure consistent results from sort(1) 78LC_ALL= C 79LANG= C 80.export LANG LC_ALL 81.endif 82 83# The driver. 84# We always pretend .MAKE was called 'make' 85# and strip ${.CURDIR}/ from the output 86# and replace anything after 'stopped in' with unit-tests 87# so the results can be compared. 88test: 89 @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 90 @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 91 ${TOOL_TR} -d '\015' | \ 92 ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[^:]*:,make:,' \ 93 -e '/stopped/s, /.*, unit-tests,' \ 94 -e 's,${.CURDIR:C/\./\\\./g}/,,g' \ 95 -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \ 96 tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 97 ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out 98 99accept: 100 mv test.out ${srcdir}/test.exp 101 102