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