Makefile revision 1.7
11.7Ssjg# $Id: Makefile,v 1.7 2003/08/08 06:42:38 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.7SsjgUNIT_TESTS:= ${.PARSEDIR} 181.7Ssjg 191.5Ssjgall: mod-ts varcmd 201.1Ssjg 211.1SsjgLIST= one two three 221.1SsjgLIST+= four five six 231.1Ssjg 241.1SsjgFU_mod-ts = a / b / cool 251.1Ssjg 261.1Ssjgmod-ts: 271.3Ssjg @echo 'LIST="${LIST}"' 281.3Ssjg @echo 'LIST:ts,="${LIST:ts,}"' 291.3Ssjg @echo 'LIST:ts/:tu="${LIST:ts/:tu}"' 301.3Ssjg @echo 'LIST:tu:ts/="${LIST:tu:ts/}"' 311.3Ssjg @echo 'LIST:ts:="${LIST:ts:}"' 321.3Ssjg @echo 'LIST:ts="${LIST:ts}"' 331.3Ssjg @echo 'LIST:ts:S/two/2/="${LIST:ts:S/two/2/}"' 341.3Ssjg @echo 'LIST:S/two/2/:ts="${LIST:S/two/2/:ts}"' 351.3Ssjg @echo 'LIST:ts/:S/two/2/="${LIST:ts/:S/two/2/}"' 361.4Ssjg @echo "Pretend the '/' in '/n' etc. below are back-slashes." 371.4Ssjg @echo 'LIST:ts/n="${LIST:ts\n}"' 381.4Ssjg @echo 'LIST:ts/t="${LIST:ts\t}"' 391.4Ssjg @echo 'LIST:ts/012:tu="${LIST:ts\012:tu}"' 401.3Ssjg @echo 'LIST:tx="${LIST:tx}"' 411.6Ssjg @echo 'LIST:ts/x:tu="${LIST:ts\x:tu}"' 421.3Ssjg @echo 'FU_$@="${FU_${@:ts}:ts}"' 431.3Ssjg @echo 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?' 441.1Ssjg 451.5Ssjg.PHONY: varcmd 461.5Ssjgvarcmd: 471.7Ssjg @${.MAKE} -f ${UNIT_TESTS}/varcmd 481.5Ssjg 491.1Ssjgclean: 501.1Ssjg rm -f *.out *.fail *.core 511.1Ssjg 521.1Ssjg.include <bsd.obj.mk> 531.1Ssjg 541.1SsjgTEST_MAKE?= ${MAKE} 551.1Ssjg 561.1Ssjg# here is the driver 571.1Ssjgtest: 581.1Ssjg @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 591.6Ssjg @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 601.2Ssjg sed 's,^${TEST_MAKE:T}:,make:,' > ${.TARGET}.out || { \ 611.1Ssjg tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 621.7Ssjg diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out 631.1Ssjg 641.1Ssjgaccept: 651.1Ssjg mv test.out ${.CURDIR}/test.exp 661.1Ssjg 67