1 # $Id: Makefile,v 1.11 2004/02/20 09:03:26 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 17 UNIT_TESTS:= ${.PARSEDIR} 18 19 # Simple sub-makefiles - we run them as a black box 20 # keep the list sorted. 21 SUBFILES= \ 22 modmatch \ 23 modts \ 24 modword \ 25 ternary \ 26 varcmd 27 28 all: ${SUBFILES} 29 30 # the tests are actually done with sub-makes. 31 .PHONY: ${SUBFILES} 32 ${SUBFILES}: 33 @${.MAKE} -k -f ${UNIT_TESTS}/$@ 34 35 clean: 36 rm -f *.out *.fail *.core 37 38 .include <bsd.obj.mk> 39 40 TEST_MAKE?= ${MAKE} 41 42 # The driver. 43 # We always pretend .MAKE was called 'make' so the results 44 # can be compared. 45 test: 46 @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 47 @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 48 sed 's,^${TEST_MAKE:T}:,make:,' > ${.TARGET}.out || { \ 49 tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 50 diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out 51 52 accept: 53 mv test.out ${.CURDIR}/test.exp 54 55