2013-12-06 12:04:52 +01:00
|
|
|
# $NetBSD: Makefile,v 1.38 2013/08/28 21:56:50 sjg Exp $
|
2010-02-04 17:52:54 +01: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 in its own suitably
|
|
|
|
# named makefile which should be added to SUBFILES to hook it in.
|
|
|
|
#
|
|
|
|
|
|
|
|
.MAIN: all
|
|
|
|
|
|
|
|
UNIT_TESTS:= ${.PARSEDIR}
|
|
|
|
|
|
|
|
# Simple sub-makefiles - we run them as a black box
|
|
|
|
# keep the list sorted.
|
|
|
|
SUBFILES= \
|
|
|
|
comment \
|
|
|
|
cond1 \
|
2012-06-06 16:24:31 +02:00
|
|
|
error \
|
2010-02-04 17:52:54 +01:00
|
|
|
export \
|
|
|
|
export-all \
|
2013-12-06 12:04:52 +01:00
|
|
|
export-env \
|
2012-06-06 16:24:31 +02:00
|
|
|
doterror \
|
2010-02-04 17:52:54 +01:00
|
|
|
dotwait \
|
2012-12-11 18:41:20 +01:00
|
|
|
forloop \
|
2010-02-04 17:52:54 +01:00
|
|
|
forsubst \
|
2012-06-06 16:24:31 +02:00
|
|
|
hash \
|
|
|
|
misc \
|
2010-02-04 17:52:54 +01:00
|
|
|
moderrs \
|
|
|
|
modmatch \
|
|
|
|
modmisc \
|
|
|
|
modorder \
|
|
|
|
modts \
|
|
|
|
modword \
|
2013-12-06 12:04:52 +01:00
|
|
|
order \
|
2012-06-06 16:24:31 +02:00
|
|
|
phony-end \
|
2010-02-04 17:52:54 +01:00
|
|
|
posix \
|
|
|
|
qequals \
|
2013-12-06 12:04:52 +01:00
|
|
|
sunshcmd \
|
2012-06-06 16:24:31 +02:00
|
|
|
sysv \
|
2010-02-04 17:52:54 +01:00
|
|
|
ternary \
|
|
|
|
unexport \
|
|
|
|
unexport-env \
|
|
|
|
varcmd
|
|
|
|
|
|
|
|
all: ${SUBFILES}
|
|
|
|
|
2012-06-06 16:24:31 +02:00
|
|
|
flags.doterror=
|
2013-12-06 12:04:52 +01:00
|
|
|
flags.order=-j1
|
2012-06-06 16:24:31 +02:00
|
|
|
|
2010-02-04 17:52:54 +01:00
|
|
|
# the tests are actually done with sub-makes.
|
|
|
|
.PHONY: ${SUBFILES}
|
|
|
|
.PRECIOUS: ${SUBFILES}
|
|
|
|
${SUBFILES}:
|
2012-06-06 16:24:31 +02:00
|
|
|
-@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@
|
2010-02-04 17:52:54 +01:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f *.out *.fail *.core
|
|
|
|
|
2012-06-06 16:24:31 +02:00
|
|
|
.-include <bsd.obj.mk>
|
2010-02-04 17:52:54 +01:00
|
|
|
|
|
|
|
TEST_MAKE?= ${.MAKE}
|
2012-06-06 16:24:31 +02:00
|
|
|
TOOL_SED?= sed
|
|
|
|
|
|
|
|
# ensure consistent results from sort(1)
|
|
|
|
LC_ALL= C
|
|
|
|
LANG= C
|
|
|
|
.export LANG LC_ALL
|
2010-02-04 17:52:54 +01:00
|
|
|
|
|
|
|
# The driver.
|
|
|
|
# We always pretend .MAKE was called 'make'
|
|
|
|
# and strip ${.CURDIR}/ from the output
|
|
|
|
# and replace anything after 'stopped in' with unit-tests
|
|
|
|
# so the results can be compared.
|
|
|
|
test:
|
|
|
|
@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
|
|
|
|
@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
|
2013-12-06 12:04:52 +01:00
|
|
|
${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[^:]*:,make:,' \
|
2010-02-04 17:52:54 +01:00
|
|
|
-e '/stopped/s, /.*, unit-tests,' \
|
|
|
|
-e 's,${.CURDIR:C/\./\\\./g}/,,g' \
|
|
|
|
-e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
|
|
|
|
tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
|
|
|
|
diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
|
|
|
|
|
|
|
|
accept:
|
|
|
|
mv test.out ${.CURDIR}/test.exp
|
|
|
|
|