Makefile revision 1.12
11.12Ssjg# $Id: Makefile,v 1.12 2004/04/08 00:59:01 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.11Ssjg# Each feature should get its own set of tests in its own suitably 121.11Ssjg# named makefile which should be added to SUBFILES to hook it in. 131.1Ssjg# 141.1Ssjg 151.1Ssjg.MAIN: all 161.1Ssjg 171.7SsjgUNIT_TESTS:= ${.PARSEDIR} 181.7Ssjg 191.11Ssjg# Simple sub-makefiles - we run them as a black box 201.11Ssjg# keep the list sorted. 211.11SsjgSUBFILES= \ 221.12Ssjg cond1 \ 231.11Ssjg modmatch \ 241.11Ssjg modts \ 251.11Ssjg modword \ 261.11Ssjg ternary \ 271.11Ssjg varcmd 281.11Ssjg 291.11Ssjgall: ${SUBFILES} 301.11Ssjg 311.11Ssjg# the tests are actually done with sub-makes. 321.11Ssjg.PHONY: ${SUBFILES} 331.11Ssjg${SUBFILES}: 341.9Ssjg @${.MAKE} -k -f ${UNIT_TESTS}/$@ 351.9Ssjg 361.1Ssjgclean: 371.1Ssjg rm -f *.out *.fail *.core 381.1Ssjg 391.1Ssjg.include <bsd.obj.mk> 401.1Ssjg 411.1SsjgTEST_MAKE?= ${MAKE} 421.1Ssjg 431.11Ssjg# The driver. 441.12Ssjg# We always pretend .MAKE was called 'make' 451.12Ssjg# and strip ${.CURDIR}/ from the output 461.12Ssjg# so the results can be compared. 471.1Ssjgtest: 481.1Ssjg @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 491.6Ssjg @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 501.12Ssjg sed -e 's,^${TEST_MAKE:T}:,make:,' -e 's,${.CURDIR}/,,g' > ${.TARGET}.out || { \ 511.1Ssjg tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 521.7Ssjg diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out 531.1Ssjg 541.1Ssjgaccept: 551.1Ssjg mv test.out ${.CURDIR}/test.exp 561.1Ssjg 57