Makefile.in revision 237578
1# $Id: Makefile.in,v 1.38 2012/06/19 23:38:48 sjg Exp $ 2# 3# $NetBSD: Makefile,v 1.34 2012/06/19 23:25:53 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 doterror \ 32 dotwait \ 33 forloop \ 34 forsubst \ 35 hash \ 36 misc \ 37 moderrs \ 38 modmatch \ 39 modmisc \ 40 modorder \ 41 modts \ 42 modword \ 43 phony-end \ 44 posix \ 45 qequals \ 46 sysv \ 47 ternary \ 48 unexport \ 49 unexport-env \ 50 varcmd 51 52all: ${SUBFILES} 53 54flags.doterror= 55 56# the tests are actually done with sub-makes. 57.PHONY: ${SUBFILES} 58.PRECIOUS: ${SUBFILES} 59${SUBFILES}: 60 -@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@ 61 62clean: 63 rm -f *.out *.fail *.core 64 65.-include <bsd.obj.mk> 66 67TEST_MAKE?= ${.MAKE} 68TOOL_SED?= sed 69TOOL_TR?= tr 70TOOL_DIFF?= diff 71DIFF_FLAGS?= @diff_u@ 72 73# ensure consistent results from sort(1) 74LC_ALL= C 75LANG= C 76.export LANG LC_ALL 77 78# The driver. 79# We always pretend .MAKE was called 'make' 80# and strip ${.CURDIR}/ from the output 81# and replace anything after 'stopped in' with unit-tests 82# so the results can be compared. 83test: 84 @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 85 @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 86 ${TOOL_TR} -d '\015' | \ 87 ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \ 88 -e '/stopped/s, /.*, unit-tests,' \ 89 -e 's,${.CURDIR:C/\./\\\./g}/,,g' \ 90 -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \ 91 tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 92 ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out 93 94accept: 95 mv test.out ${srcdir}/test.exp 96 97