Makefile revision 1.5
11.5Ssjg# $Id: Makefile,v 1.5 2003/07/31 00:46:15 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.5Ssjgall: mod-ts varcmd
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.5Ssjg.PHONY: varcmd
441.5Ssjgvarcmd:
451.5Ssjg	@${.MAKE} -f ${MAKEFILE:H}/varcmd
461.5Ssjg
471.1Ssjgclean:
481.1Ssjg	rm -f *.out *.fail *.core
491.1Ssjg
501.1Ssjg.include <bsd.obj.mk>
511.1Ssjg
521.1SsjgTEST_MAKE?= ${MAKE}
531.1Ssjg
541.1Ssjg# here is the driver
551.1Ssjgtest:
561.1Ssjg	@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
571.5Ssjg	@cd ${.OBJDIR}; ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
581.2Ssjg	sed 's,^${TEST_MAKE:T}:,make:,' > ${.TARGET}.out || { \
591.1Ssjg	tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
601.1Ssjg	diff -u ${.CURDIR}/${.TARGET}.exp ${.TARGET}.out
611.1Ssjg
621.1Ssjgaccept:
631.1Ssjg	mv test.out ${.CURDIR}/test.exp
641.1Ssjg
65