Makefile revision 1.13
1# $Id: Makefile,v 1.13 2004/05/07 08:12:16 sjg Exp $ 2# 3# Unit tests for make(1) 4# The main targets are: 5# 6# all: run all the tests 7# test: run 'all', capture output and compare to expected results 8# accept: move generated output to expected results 9# 10# Adding a test case. 11# Each feature should get its own set of tests in its own suitably 12# named makefile which should be added to SUBFILES to hook it in. 13# 14 15.MAIN: all 16 17UNIT_TESTS:= ${.PARSEDIR} 18 19# Simple sub-makefiles - we run them as a black box 20# keep the list sorted. 21SUBFILES= \ 22 cond1 \ 23 modmatch \ 24 modts \ 25 modword \ 26 posix \ 27 ternary \ 28 varcmd 29 30all: ${SUBFILES} 31 32# the tests are actually done with sub-makes. 33.PHONY: ${SUBFILES} 34${SUBFILES}: 35 -@${.MAKE} -k -f ${UNIT_TESTS}/$@ 36 37clean: 38 rm -f *.out *.fail *.core 39 40.include <bsd.obj.mk> 41 42TEST_MAKE?= ${MAKE} 43 44# The driver. 45# We always pretend .MAKE was called 'make' 46# and strip ${.CURDIR}/ from the output 47# and replace anything after 'stopped in' with unit-tests 48# so the results can be compared. 49test: 50 @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 51 @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 52 sed -e 's,^${TEST_MAKE:T}:,make:,' \ 53 -e '/stopped/s, /.*, unit-tests,' \ 54 -e 's,${.CURDIR}/,,g' \ 55 -e 's,${UNIT_TESTS}/,,g' > ${.TARGET}.out || { \ 56 tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 57 diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out 58 59accept: 60 mv test.out ${.CURDIR}/test.exp 61 62