2005-06-16 02:32:22 +04:00
|
|
|
# $NetBSD: Makefile,v 1.16 2005/06/15 22:32:22 rpaulo 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.
|
2004-02-20 12:03:26 +03:00
|
|
|
# Each feature should get its own set of tests in its own suitably
|
|
|
|
# named makefile which should be added to SUBFILES to hook it in.
|
2003-07-29 02:52:10 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
.MAIN: all
|
|
|
|
|
2003-08-08 10:42:38 +04:00
|
|
|
UNIT_TESTS:= ${.PARSEDIR}
|
|
|
|
|
2004-02-20 12:03:26 +03:00
|
|
|
# Simple sub-makefiles - we run them as a black box
|
|
|
|
# keep the list sorted.
|
|
|
|
SUBFILES= \
|
2005-06-16 02:32:22 +04:00
|
|
|
comment \
|
2004-04-08 04:59:01 +04:00
|
|
|
cond1 \
|
2004-02-20 12:03:26 +03:00
|
|
|
modmatch \
|
2005-06-01 21:17:34 +04:00
|
|
|
modorder \
|
2004-02-20 12:03:26 +03:00
|
|
|
modts \
|
|
|
|
modword \
|
2004-05-07 12:12:15 +04:00
|
|
|
posix \
|
2004-02-20 12:03:26 +03:00
|
|
|
ternary \
|
|
|
|
varcmd
|
2003-07-29 02:52:10 +04:00
|
|
|
|
2004-02-20 12:03:26 +03:00
|
|
|
all: ${SUBFILES}
|
2003-07-29 02:52:10 +04:00
|
|
|
|
2004-02-20 12:03:26 +03:00
|
|
|
# the tests are actually done with sub-makes.
|
|
|
|
.PHONY: ${SUBFILES}
|
|
|
|
${SUBFILES}:
|
2004-05-07 12:12:15 +04:00
|
|
|
-@${.MAKE} -k -f ${UNIT_TESTS}/$@
|
2004-01-09 03:56:44 +03:00
|
|
|
|
2003-07-29 02:52:10 +04:00
|
|
|
clean:
|
|
|
|
rm -f *.out *.fail *.core
|
|
|
|
|
|
|
|
.include <bsd.obj.mk>
|
|
|
|
|
2005-06-01 21:17:34 +04:00
|
|
|
TEST_MAKE?= ${.MAKE}
|
2003-07-29 02:52:10 +04:00
|
|
|
|
2004-02-20 12:03:26 +03:00
|
|
|
# The driver.
|
2004-04-08 04:59:01 +04:00
|
|
|
# We always pretend .MAKE was called 'make'
|
|
|
|
# and strip ${.CURDIR}/ from the output
|
2004-05-07 12:12:15 +04:00
|
|
|
# and replace anything after 'stopped in' with unit-tests
|
2004-04-08 04:59:01 +04:00
|
|
|
# so the results can be compared.
|
2003-07-29 02:52:10 +04:00
|
|
|
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 | \
|
2004-05-07 12:12:15 +04:00
|
|
|
sed -e 's,^${TEST_MAKE:T}:,make:,' \
|
|
|
|
-e '/stopped/s, /.*, unit-tests,' \
|
|
|
|
-e 's,${.CURDIR}/,,g' \
|
|
|
|
-e 's,${UNIT_TESTS}/,,g' > ${.TARGET}.out || { \
|
2003-07-29 02:52:10 +04:00
|
|
|
tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
|
2003-08-08 10:42:38 +04:00
|
|
|
diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
|
2003-07-29 02:52:10 +04:00
|
|
|
|
|
|
|
accept:
|
|
|
|
mv test.out ${.CURDIR}/test.exp
|
|
|
|
|