1 # $Id: Makefile,v 1.4 2003/07/29 08:44:42 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 which should be hooked 12 # into the 'all' target. 13 # 14 15 .MAIN: all 16 17 all: mod-ts 18 19 LIST= one two three 20 LIST+= four five six 21 22 FU_mod-ts = a / b / cool 23 24 mod-ts: 25 @echo 'LIST="${LIST}"' 26 @echo 'LIST:ts,="${LIST:ts,}"' 27 @echo 'LIST:ts/:tu="${LIST:ts/:tu}"' 28 @echo 'LIST:tu:ts/="${LIST:tu:ts/}"' 29 @echo 'LIST:ts:="${LIST:ts:}"' 30 @echo 'LIST:ts="${LIST:ts}"' 31 @echo 'LIST:ts:S/two/2/="${LIST:ts:S/two/2/}"' 32 @echo 'LIST:S/two/2/:ts="${LIST:S/two/2/:ts}"' 33 @echo 'LIST:ts/:S/two/2/="${LIST:ts/:S/two/2/}"' 34 @echo "Pretend the '/' in '/n' etc. below are back-slashes." 35 @echo 'LIST:ts/n="${LIST:ts\n}"' 36 @echo 'LIST:ts/t="${LIST:ts\t}"' 37 @echo 'LIST:ts/012:tu="${LIST:ts\012:tu}"' 38 @echo 'LIST:tx="${LIST:tx}"' 39 @echo 'LIST:ts/a:tu="${LIST:ts\a:tu}"' 40 @echo 'FU_$@="${FU_${@:ts}:ts}"' 41 @echo 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?' 42 43 clean: 44 rm -f *.out *.fail *.core 45 46 .include <bsd.obj.mk> 47 48 TEST_MAKE?= ${MAKE} 49 50 # here is the driver 51 test: 52 @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 53 @${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 54 sed 's,^${TEST_MAKE:T}:,make:,' > ${.TARGET}.out || { \ 55 tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 56 diff -u ${.CURDIR}/${.TARGET}.exp ${.TARGET}.out 57 58 accept: 59 mv test.out ${.CURDIR}/test.exp 60 61