1 1.2 sjg # $Id: Makefile,v 1.2 2003/07/29 06:35:09 sjg Exp $ 2 1.1 sjg # 3 1.1 sjg # Unit tests for make(1) 4 1.1 sjg # The main targets are: 5 1.1 sjg # 6 1.1 sjg # all: run all the tests 7 1.1 sjg # test: run 'all', capture output and compare to expected results 8 1.1 sjg # accept: move generated output to expected results 9 1.1 sjg # 10 1.1 sjg # Adding a test case. 11 1.1 sjg # Each feature should get its own set of tests which should be hooked 12 1.1 sjg # into the 'all' target. 13 1.1 sjg # 14 1.1 sjg 15 1.1 sjg .MAIN: all 16 1.1 sjg 17 1.1 sjg all: mod-ts 18 1.1 sjg 19 1.1 sjg LIST= one two three 20 1.1 sjg LIST+= four five six 21 1.1 sjg 22 1.1 sjg FU_mod-ts = a / b / cool 23 1.1 sjg 24 1.1 sjg mod-ts: 25 1.1 sjg @echo LIST='${LIST}' 26 1.1 sjg @echo LIST:ts,='${LIST:ts,}' 27 1.1 sjg @echo LIST:ts/:tu='${LIST:ts/:tu}' 28 1.1 sjg @echo LIST:tu:ts/='${LIST:tu:ts/}' 29 1.1 sjg @echo LIST:ts:='${LIST:ts:}' 30 1.1 sjg @echo LIST:ts='${LIST:ts}' 31 1.1 sjg @echo LIST:ts:S/two/2/='${LIST:ts:S/two/2/}' 32 1.1 sjg @echo LIST:S/two/2/:ts='${LIST:S/two/2/:ts}' 33 1.1 sjg @echo LIST:ts/:S/two/2/='${LIST:ts/:S/two/2/}' 34 1.1 sjg @echo "LIST:ts\n='${LIST:ts\n}'" 35 1.1 sjg @echo "LIST:ts\t='${LIST:ts\t}'" 36 1.1 sjg @echo "LIST:ts\012:tu='${LIST:ts\012:tu}'" 37 1.1 sjg @echo "LIST:tx='${LIST:tx}'" 38 1.1 sjg @echo "LIST:ts\a:tu='${LIST:ts\a:tu}'" 39 1.1 sjg @echo "FU_$@='${FU_${@:ts}:ts}'" 40 1.1 sjg @echo "FU_$@:ts:T='${FU_${@:ts}:ts:T}' == cool?" 41 1.1 sjg 42 1.1 sjg clean: 43 1.1 sjg rm -f *.out *.fail *.core 44 1.1 sjg 45 1.1 sjg .include <bsd.obj.mk> 46 1.1 sjg 47 1.1 sjg TEST_MAKE?= ${MAKE} 48 1.1 sjg 49 1.1 sjg # here is the driver 50 1.1 sjg test: 51 1.1 sjg @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 52 1.2 sjg @${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 53 1.2 sjg sed 's,^${TEST_MAKE:T}:,make:,' > ${.TARGET}.out || { \ 54 1.1 sjg tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 55 1.1 sjg diff -u ${.CURDIR}/${.TARGET}.exp ${.TARGET}.out 56 1.1 sjg 57 1.1 sjg accept: 58 1.1 sjg mv test.out ${.CURDIR}/test.exp 59 1.1 sjg 60