Makefile.in revision 249033
1249033Ssjg# $Id: Makefile.in,v 1.42 2013/03/23 02:31:13 sjg Exp $ 2236769Sobrien# 3249033Ssjg# $NetBSD: Makefile,v 1.36 2013/03/22 16:36:46 sjg Exp $ 4236769Sobrien# 5236769Sobrien# Unit tests for make(1) 6236769Sobrien# The main targets are: 7236769Sobrien# 8236769Sobrien# all: run all the tests 9236769Sobrien# test: run 'all', capture output and compare to expected results 10236769Sobrien# accept: move generated output to expected results 11236769Sobrien# 12236769Sobrien# Adding a test case. 13236769Sobrien# Each feature should get its own set of tests in its own suitably 14236769Sobrien# named makefile which should be added to SUBFILES to hook it in. 15236769Sobrien# 16236769Sobrien 17236769Sobriensrcdir= @srcdir@ 18236769Sobrien 19236769Sobrien.MAIN: all 20236769Sobrien 21236769SobrienUNIT_TESTS:= ${srcdir} 22236769Sobrien 23236769Sobrien# Simple sub-makefiles - we run them as a black box 24236769Sobrien# keep the list sorted. 25236769SobrienSUBFILES= \ 26236769Sobrien comment \ 27236769Sobrien cond1 \ 28236769Sobrien error \ 29236769Sobrien export \ 30236769Sobrien export-all \ 31249033Ssjg export-env \ 32236769Sobrien doterror \ 33236769Sobrien dotwait \ 34237578Sobrien forloop \ 35236769Sobrien forsubst \ 36236769Sobrien hash \ 37236769Sobrien misc \ 38236769Sobrien moderrs \ 39236769Sobrien modmatch \ 40236769Sobrien modmisc \ 41236769Sobrien modorder \ 42236769Sobrien modts \ 43236769Sobrien modword \ 44243115Ssjg order \ 45236769Sobrien phony-end \ 46236769Sobrien posix \ 47236769Sobrien qequals \ 48236769Sobrien sysv \ 49236769Sobrien ternary \ 50236769Sobrien unexport \ 51236769Sobrien unexport-env \ 52236769Sobrien varcmd 53236769Sobrien 54236769Sobrienall: ${SUBFILES} 55236769Sobrien 56236769Sobrienflags.doterror= 57243115Ssjgflags.order=-j1 58236769Sobrien 59236769Sobrien# the tests are actually done with sub-makes. 60236769Sobrien.PHONY: ${SUBFILES} 61236769Sobrien.PRECIOUS: ${SUBFILES} 62236769Sobrien${SUBFILES}: 63236769Sobrien -@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@ 64236769Sobrien 65236769Sobrienclean: 66236769Sobrien rm -f *.out *.fail *.core 67236769Sobrien 68246223Ssjg.-include <obj.mk> 69236769Sobrien 70236769SobrienTEST_MAKE?= ${.MAKE} 71236769SobrienTOOL_SED?= sed 72236769SobrienTOOL_TR?= tr 73236769SobrienTOOL_DIFF?= diff 74236769SobrienDIFF_FLAGS?= @diff_u@ 75236769Sobrien 76249033Ssjg.if defined(.PARSEDIR) 77236769Sobrien# ensure consistent results from sort(1) 78236769SobrienLC_ALL= C 79236769SobrienLANG= C 80236769Sobrien.export LANG LC_ALL 81249033Ssjg.endif 82236769Sobrien 83236769Sobrien# The driver. 84236769Sobrien# We always pretend .MAKE was called 'make' 85236769Sobrien# and strip ${.CURDIR}/ from the output 86236769Sobrien# and replace anything after 'stopped in' with unit-tests 87236769Sobrien# so the results can be compared. 88236769Sobrientest: 89236769Sobrien @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 90236769Sobrien @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 91236769Sobrien ${TOOL_TR} -d '\015' | \ 92236769Sobrien ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \ 93236769Sobrien -e '/stopped/s, /.*, unit-tests,' \ 94236769Sobrien -e 's,${.CURDIR:C/\./\\\./g}/,,g' \ 95236769Sobrien -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \ 96236769Sobrien tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 97236769Sobrien ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out 98236769Sobrien 99236769Sobrienaccept: 100236769Sobrien mv test.out ${srcdir}/test.exp 101236769Sobrien 102