Makefile revision 1.2
11.2Ssjg# $Id: Makefile,v 1.2 2003/07/29 06:35:09 sjg Exp $ 21.1Ssjg# 31.1Ssjg# Unit tests for make(1) 41.1Ssjg# The main targets are: 51.1Ssjg# 61.1Ssjg# all: run all the tests 71.1Ssjg# test: run 'all', capture output and compare to expected results 81.1Ssjg# accept: move generated output to expected results 91.1Ssjg# 101.1Ssjg# Adding a test case. 111.1Ssjg# Each feature should get its own set of tests which should be hooked 121.1Ssjg# into the 'all' target. 131.1Ssjg# 141.1Ssjg 151.1Ssjg.MAIN: all 161.1Ssjg 171.1Ssjgall: mod-ts 181.1Ssjg 191.1SsjgLIST= one two three 201.1SsjgLIST+= four five six 211.1Ssjg 221.1SsjgFU_mod-ts = a / b / cool 231.1Ssjg 241.1Ssjgmod-ts: 251.1Ssjg @echo LIST='${LIST}' 261.1Ssjg @echo LIST:ts,='${LIST:ts,}' 271.1Ssjg @echo LIST:ts/:tu='${LIST:ts/:tu}' 281.1Ssjg @echo LIST:tu:ts/='${LIST:tu:ts/}' 291.1Ssjg @echo LIST:ts:='${LIST:ts:}' 301.1Ssjg @echo LIST:ts='${LIST:ts}' 311.1Ssjg @echo LIST:ts:S/two/2/='${LIST:ts:S/two/2/}' 321.1Ssjg @echo LIST:S/two/2/:ts='${LIST:S/two/2/:ts}' 331.1Ssjg @echo LIST:ts/:S/two/2/='${LIST:ts/:S/two/2/}' 341.1Ssjg @echo "LIST:ts\n='${LIST:ts\n}'" 351.1Ssjg @echo "LIST:ts\t='${LIST:ts\t}'" 361.1Ssjg @echo "LIST:ts\012:tu='${LIST:ts\012:tu}'" 371.1Ssjg @echo "LIST:tx='${LIST:tx}'" 381.1Ssjg @echo "LIST:ts\a:tu='${LIST:ts\a:tu}'" 391.1Ssjg @echo "FU_$@='${FU_${@:ts}:ts}'" 401.1Ssjg @echo "FU_$@:ts:T='${FU_${@:ts}:ts:T}' == cool?" 411.1Ssjg 421.1Ssjgclean: 431.1Ssjg rm -f *.out *.fail *.core 441.1Ssjg 451.1Ssjg.include <bsd.obj.mk> 461.1Ssjg 471.1SsjgTEST_MAKE?= ${MAKE} 481.1Ssjg 491.1Ssjg# here is the driver 501.1Ssjgtest: 511.1Ssjg @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 521.2Ssjg @${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 531.2Ssjg sed 's,^${TEST_MAKE:T}:,make:,' > ${.TARGET}.out || { \ 541.1Ssjg tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 551.1Ssjg diff -u ${.CURDIR}/${.TARGET}.exp ${.TARGET}.out 561.1Ssjg 571.1Ssjgaccept: 581.1Ssjg mv test.out ${.CURDIR}/test.exp 591.1Ssjg 60