Makefile revision 1.16
11.16Srpaulo# $NetBSD: Makefile,v 1.16 2005/06/15 22:32:22 rpaulo 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.16Srpaulo comment \ 231.12Ssjg cond1 \ 241.11Ssjg modmatch \ 251.15Ssjg modorder \ 261.11Ssjg modts \ 271.11Ssjg modword \ 281.13Ssjg posix \ 291.11Ssjg ternary \ 301.11Ssjg varcmd 311.11Ssjg 321.11Ssjgall: ${SUBFILES} 331.11Ssjg 341.11Ssjg# the tests are actually done with sub-makes. 351.11Ssjg.PHONY: ${SUBFILES} 361.11Ssjg${SUBFILES}: 371.13Ssjg -@${.MAKE} -k -f ${UNIT_TESTS}/$@ 381.9Ssjg 391.1Ssjgclean: 401.1Ssjg rm -f *.out *.fail *.core 411.1Ssjg 421.1Ssjg.include <bsd.obj.mk> 431.1Ssjg 441.15SsjgTEST_MAKE?= ${.MAKE} 451.1Ssjg 461.11Ssjg# The driver. 471.12Ssjg# We always pretend .MAKE was called 'make' 481.12Ssjg# and strip ${.CURDIR}/ from the output 491.13Ssjg# and replace anything after 'stopped in' with unit-tests 501.12Ssjg# so the results can be compared. 511.1Ssjgtest: 521.1Ssjg @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" 531.6Ssjg @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ 541.13Ssjg sed -e 's,^${TEST_MAKE:T}:,make:,' \ 551.13Ssjg -e '/stopped/s, /.*, unit-tests,' \ 561.13Ssjg -e 's,${.CURDIR}/,,g' \ 571.13Ssjg -e 's,${UNIT_TESTS}/,,g' > ${.TARGET}.out || { \ 581.1Ssjg tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } 591.7Ssjg diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out 601.1Ssjg 611.1Ssjgaccept: 621.1Ssjg mv test.out ${.CURDIR}/test.exp 631.1Ssjg 64