Makefile.in revision 255253
1255253Ssjg# $Id: Makefile.in,v 1.44 2013/08/28 22:09:29 sjg Exp $ 2236769Sobrien# 3255253Ssjg# $NetBSD: Makefile,v 1.38 2013/08/28 21:56:50 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 \ 48255253Ssjg sunshcmd \ 49236769Sobrien sysv \ 50236769Sobrien ternary \ 51236769Sobrien unexport \ 52236769Sobrien unexport-env \ 53236769Sobrien varcmd 54236769Sobrien 55236769Sobrienall: ${SUBFILES} 56236769Sobrien 57236769Sobrienflags.doterror= 58243115Ssjgflags.order=-j1 59236769Sobrien 60236769Sobrien# the tests are actually done with sub-makes. 61236769Sobrien.PHONY: ${SUBFILES} 62236769Sobrien.PRECIOUS: ${SUBFILES} 63236769Sobrien${SUBFILES}: 64236769Sobrien -@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@ 65236769Sobrien 66236769Sobrienclean: 67236769Sobrien rm -f *.out *.fail *.core 68236769Sobrien 69246223Ssjg.-include <obj.mk> 70236769Sobrien 71236769SobrienTEST_MAKE?= ${.MAKE} 72236769SobrienTOOL_SED?= sed 73236769SobrienTOOL_TR?= tr 74236769SobrienTOOL_DIFF?= diff 75236769SobrienDIFF_FLAGS?= @diff_u@ 76236769Sobrien 77249033Ssjg.if defined(.PARSEDIR) 78236769Sobrien# ensure consistent results from sort(1) 79236769SobrienLC_ALL= C 80236769SobrienLANG= C 81236769Sobrien.export LANG LC_ALL 82249033Ssjg.endif 83236769Sobrien 84236769Sobrien# The driver. 85236769Sobrien# We always pretend .MAKE was called 'make' 86236769Sobrien# and strip ${.CURDIR}/ from the output 87236769Sobrien# and replace anything after 'stopped in' with unit-tests 88236769Sobrien# so the results can be compared. 89236769Sobrientest: 90236769Sobrien @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 91236769Sobrien @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 92236769Sobrien ${TOOL_TR} -d '\015' | \ 93253883Ssjg ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[^:]*:,make:,' \ 94236769Sobrien -e '/stopped/s, /.*, unit-tests,' \ 95236769Sobrien -e 's,${.CURDIR:C/\./\\\./g}/,,g' \ 96236769Sobrien -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \ 97236769Sobrien tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 98236769Sobrien ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out 99236769Sobrien 100236769Sobrienaccept: 101236769Sobrien mv test.out ${srcdir}/test.exp 102236769Sobrien 103