2003-08-01 08:57:20 +04:00
|
|
|
# $Id: Makefile,v 1.6 2003/08/01 04:57:20 sjg Exp $
|
2003-07-29 02:52:10 +04:00
|
|
|
#
|
|
|
|
# Unit tests for make(1)
|
|
|
|
# The main targets are:
|
|
|
|
#
|
|
|
|
# all: run all the tests
|
|
|
|
# test: run 'all', capture output and compare to expected results
|
|
|
|
# accept: move generated output to expected results
|
|
|
|
#
|
|
|
|
# Adding a test case.
|
|
|
|
# Each feature should get its own set of tests which should be hooked
|
|
|
|
# into the 'all' target.
|
|
|
|
#
|
|
|
|
|
|
|
|
.MAIN: all
|
|
|
|
|
2003-07-31 04:46:15 +04:00
|
|
|
all: mod-ts varcmd
|
2003-07-29 02:52:10 +04:00
|
|
|
|
|
|
|
LIST= one two three
|
|
|
|
LIST+= four five six
|
|
|
|
|
|
|
|
FU_mod-ts = a / b / cool
|
|
|
|
|
|
|
|
mod-ts:
|
2003-07-29 12:16:01 +04:00
|
|
|
@echo 'LIST="${LIST}"'
|
|
|
|
@echo 'LIST:ts,="${LIST:ts,}"'
|
|
|
|
@echo 'LIST:ts/:tu="${LIST:ts/:tu}"'
|
|
|
|
@echo 'LIST:tu:ts/="${LIST:tu:ts/}"'
|
|
|
|
@echo 'LIST:ts:="${LIST:ts:}"'
|
|
|
|
@echo 'LIST:ts="${LIST:ts}"'
|
|
|
|
@echo 'LIST:ts:S/two/2/="${LIST:ts:S/two/2/}"'
|
|
|
|
@echo 'LIST:S/two/2/:ts="${LIST:S/two/2/:ts}"'
|
|
|
|
@echo 'LIST:ts/:S/two/2/="${LIST:ts/:S/two/2/}"'
|
2003-07-29 12:44:41 +04:00
|
|
|
@echo "Pretend the '/' in '/n' etc. below are back-slashes."
|
|
|
|
@echo 'LIST:ts/n="${LIST:ts\n}"'
|
|
|
|
@echo 'LIST:ts/t="${LIST:ts\t}"'
|
|
|
|
@echo 'LIST:ts/012:tu="${LIST:ts\012:tu}"'
|
2003-07-29 12:16:01 +04:00
|
|
|
@echo 'LIST:tx="${LIST:tx}"'
|
2003-08-01 08:57:20 +04:00
|
|
|
@echo 'LIST:ts/x:tu="${LIST:ts\x:tu}"'
|
2003-07-29 12:16:01 +04:00
|
|
|
@echo 'FU_$@="${FU_${@:ts}:ts}"'
|
|
|
|
@echo 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
|
2003-07-29 02:52:10 +04:00
|
|
|
|
2003-07-31 04:46:15 +04:00
|
|
|
.PHONY: varcmd
|
|
|
|
varcmd:
|
|
|
|
@${.MAKE} -f ${MAKEFILE:H}/varcmd
|
|
|
|
|
2003-07-29 02:52:10 +04:00
|
|
|
clean:
|
|
|
|
rm -f *.out *.fail *.core
|
|
|
|
|
|
|
|
.include <bsd.obj.mk>
|
|
|
|
|
|
|
|
TEST_MAKE?= ${MAKE}
|
|
|
|
|
|
|
|
# here is the driver
|
|
|
|
test:
|
|
|
|
@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
|
2003-08-01 08:57:20 +04:00
|
|
|
@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
|
2003-07-29 10:35:09 +04:00
|
|
|
sed 's,^${TEST_MAKE:T}:,make:,' > ${.TARGET}.out || { \
|
2003-07-29 02:52:10 +04:00
|
|
|
tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
|
|
|
|
diff -u ${.CURDIR}/${.TARGET}.exp ${.TARGET}.out
|
|
|
|
|
|
|
|
accept:
|
|
|
|
mv test.out ${.CURDIR}/test.exp
|
|
|
|
|