Makefile revision 1.5
1# $Id: Makefile,v 1.5 2003/07/31 00:46:15 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
17all: mod-ts varcmd
18
19LIST= one two three
20LIST+= four five six
21
22FU_mod-ts = a / b / cool
23
24mod-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.PHONY: varcmd
44varcmd:
45	@${.MAKE} -f ${MAKEFILE:H}/varcmd
46
47clean:
48	rm -f *.out *.fail *.core
49
50.include <bsd.obj.mk>
51
52TEST_MAKE?= ${MAKE}
53
54# here is the driver
55test:
56	@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
57	@cd ${.OBJDIR}; ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
58	sed 's,^${TEST_MAKE:T}:,make:,' > ${.TARGET}.out || { \
59	tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
60	diff -u ${.CURDIR}/${.TARGET}.exp ${.TARGET}.out
61
62accept:
63	mv test.out ${.CURDIR}/test.exp
64
65