Makefile revision 1.11
11.11Ssjg# $Id: Makefile,v 1.11 2004/02/20 09:03:26 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.11Ssjg modmatch \ 231.11Ssjg modts \ 241.11Ssjg modword \ 251.11Ssjg ternary \ 261.11Ssjg varcmd 271.11Ssjg 281.11Ssjgall: ${SUBFILES} 291.11Ssjg 301.11Ssjg# the tests are actually done with sub-makes. 311.11Ssjg.PHONY: ${SUBFILES} 321.11Ssjg${SUBFILES}: 331.9Ssjg @${.MAKE} -k -f ${UNIT_TESTS}/$@ 341.9Ssjg 351.1Ssjgclean: 361.1Ssjg rm -f *.out *.fail *.core 371.1Ssjg 381.1Ssjg.include <bsd.obj.mk> 391.1Ssjg 401.1SsjgTEST_MAKE?= ${MAKE} 411.1Ssjg 421.11Ssjg# The driver. 431.11Ssjg# We always pretend .MAKE was called 'make' so the results 441.11Ssjg# can be compared. 451.1Ssjgtest: 461.1Ssjg @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 471.6Ssjg @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 481.2Ssjg sed 's,^${TEST_MAKE:T}:,make:,' > ${.TARGET}.out || { \ 491.1Ssjg tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 501.7Ssjg diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out 511.1Ssjg 521.1Ssjgaccept: 531.1Ssjg mv test.out ${.CURDIR}/test.exp 541.1Ssjg 55