Makefile.in revision 237578
1237578Sobrien# $Id: Makefile.in,v 1.38 2012/06/19 23:38:48 sjg Exp $ 2236769Sobrien# 3237578Sobrien# $NetBSD: Makefile,v 1.34 2012/06/19 23:25:53 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 \ 31236769Sobrien doterror \ 32236769Sobrien dotwait \ 33237578Sobrien forloop \ 34236769Sobrien forsubst \ 35236769Sobrien hash \ 36236769Sobrien misc \ 37236769Sobrien moderrs \ 38236769Sobrien modmatch \ 39236769Sobrien modmisc \ 40236769Sobrien modorder \ 41236769Sobrien modts \ 42236769Sobrien modword \ 43236769Sobrien phony-end \ 44236769Sobrien posix \ 45236769Sobrien qequals \ 46236769Sobrien sysv \ 47236769Sobrien ternary \ 48236769Sobrien unexport \ 49236769Sobrien unexport-env \ 50236769Sobrien varcmd 51236769Sobrien 52236769Sobrienall: ${SUBFILES} 53236769Sobrien 54236769Sobrienflags.doterror= 55236769Sobrien 56236769Sobrien# the tests are actually done with sub-makes. 57236769Sobrien.PHONY: ${SUBFILES} 58236769Sobrien.PRECIOUS: ${SUBFILES} 59236769Sobrien${SUBFILES}: 60236769Sobrien -@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@ 61236769Sobrien 62236769Sobrienclean: 63236769Sobrien rm -f *.out *.fail *.core 64236769Sobrien 65236769Sobrien.-include <bsd.obj.mk> 66236769Sobrien 67236769SobrienTEST_MAKE?= ${.MAKE} 68236769SobrienTOOL_SED?= sed 69236769SobrienTOOL_TR?= tr 70236769SobrienTOOL_DIFF?= diff 71236769SobrienDIFF_FLAGS?= @diff_u@ 72236769Sobrien 73236769Sobrien# ensure consistent results from sort(1) 74236769SobrienLC_ALL= C 75236769SobrienLANG= C 76236769Sobrien.export LANG LC_ALL 77236769Sobrien 78236769Sobrien# The driver. 79236769Sobrien# We always pretend .MAKE was called 'make' 80236769Sobrien# and strip ${.CURDIR}/ from the output 81236769Sobrien# and replace anything after 'stopped in' with unit-tests 82236769Sobrien# so the results can be compared. 83236769Sobrientest: 84236769Sobrien @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 85236769Sobrien @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 86236769Sobrien ${TOOL_TR} -d '\015' | \ 87236769Sobrien ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}:,make:,' \ 88236769Sobrien -e '/stopped/s, /.*, unit-tests,' \ 89236769Sobrien -e 's,${.CURDIR:C/\./\\\./g}/,,g' \ 90236769Sobrien -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \ 91236769Sobrien tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 92236769Sobrien ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out 93236769Sobrien 94236769Sobrienaccept: 95236769Sobrien mv test.out ${srcdir}/test.exp 96236769Sobrien 97