Makefile revision 1.4
11.4Ssjg# $Id: Makefile,v 1.4 2003/07/29 08:44:42 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.3Ssjg	@echo 'LIST="${LIST}"'
261.3Ssjg	@echo 'LIST:ts,="${LIST:ts,}"'
271.3Ssjg	@echo 'LIST:ts/:tu="${LIST:ts/:tu}"'
281.3Ssjg	@echo 'LIST:tu:ts/="${LIST:tu:ts/}"'
291.3Ssjg	@echo 'LIST:ts:="${LIST:ts:}"'
301.3Ssjg	@echo 'LIST:ts="${LIST:ts}"'
311.3Ssjg	@echo 'LIST:ts:S/two/2/="${LIST:ts:S/two/2/}"'
321.3Ssjg	@echo 'LIST:S/two/2/:ts="${LIST:S/two/2/:ts}"'
331.3Ssjg	@echo 'LIST:ts/:S/two/2/="${LIST:ts/:S/two/2/}"'
341.4Ssjg	@echo "Pretend the '/' in '/n' etc. below are back-slashes."
351.4Ssjg	@echo 'LIST:ts/n="${LIST:ts\n}"'
361.4Ssjg	@echo 'LIST:ts/t="${LIST:ts\t}"'
371.4Ssjg	@echo 'LIST:ts/012:tu="${LIST:ts\012:tu}"'
381.3Ssjg	@echo 'LIST:tx="${LIST:tx}"'
391.4Ssjg	@echo 'LIST:ts/a:tu="${LIST:ts\a:tu}"'
401.3Ssjg	@echo 'FU_$@="${FU_${@:ts}:ts}"'
411.3Ssjg	@echo 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
421.1Ssjg
431.1Ssjgclean:
441.1Ssjg	rm -f *.out *.fail *.core
451.1Ssjg
461.1Ssjg.include <bsd.obj.mk>
471.1Ssjg
481.1SsjgTEST_MAKE?= ${MAKE}
491.1Ssjg
501.1Ssjg# here is the driver
511.1Ssjgtest:
521.1Ssjg	@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
531.2Ssjg	@${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
541.2Ssjg	sed 's,^${TEST_MAKE:T}:,make:,' > ${.TARGET}.out || { \
551.1Ssjg	tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
561.1Ssjg	diff -u ${.CURDIR}/${.TARGET}.exp ${.TARGET}.out
571.1Ssjg
581.1Ssjgaccept:
591.1Ssjg	mv test.out ${.CURDIR}/test.exp
601.1Ssjg
61