1241279Smarcel# This is a generated file, do NOT edit! 2241279Smarcel# See contrib/bmake/bsd.after-import.mk 3241279Smarcel# 4241279Smarcel# $FreeBSD$ 5241279Smarcel 6241279SmarcelSRCTOP?= ${.CURDIR:H:H:H} 7241279Smarcel 8292068Ssjg# $Id: Makefile.in,v 1.48 2015/12/07 04:06:29 sjg Exp $ 9241279Smarcel# 10292068Ssjg# $NetBSD: Makefile,v 1.52 2015/05/05 21:51:09 sjg Exp $ 11241279Smarcel# 12241279Smarcel# Unit tests for make(1) 13241279Smarcel# The main targets are: 14241279Smarcel# 15241279Smarcel# all: run all the tests 16292068Ssjg# test: run 'all', and compare to expected results 17241279Smarcel# accept: move generated output to expected results 18241279Smarcel# 19241279Smarcel# Adding a test case. 20241279Smarcel# Each feature should get its own set of tests in its own suitably 21292068Ssjg# named makefile (*.mk), with its own set of expected results (*.exp), 22292068Ssjg# and it should be added to the TESTNAMES list. 23241279Smarcel# 24241279Smarcel 25241279Smarcelsrcdir= ${SRCTOP}/contrib/bmake/unit-tests 26241279Smarcel 27241279Smarcel.MAIN: all 28241279Smarcel 29241279SmarcelUNIT_TESTS:= ${srcdir} 30292068Ssjg.PATH: ${UNIT_TESTS} 31241279Smarcel 32292068Ssjg# Each test is in a sub-makefile. 33292068Ssjg# Keep the list sorted. 34292068SsjgTESTNAMES= \ 35241279Smarcel comment \ 36241279Smarcel cond1 \ 37292068Ssjg cond2 \ 38241279Smarcel error \ 39241279Smarcel export \ 40241279Smarcel export-all \ 41249033Ssjg export-env \ 42241279Smarcel doterror \ 43241279Smarcel dotwait \ 44241279Smarcel forloop \ 45241279Smarcel forsubst \ 46241279Smarcel hash \ 47241279Smarcel misc \ 48241279Smarcel moderrs \ 49241279Smarcel modmatch \ 50241279Smarcel modmisc \ 51241279Smarcel modorder \ 52241279Smarcel modts \ 53241279Smarcel modword \ 54243115Ssjg order \ 55241279Smarcel posix \ 56241279Smarcel qequals \ 57255253Ssjg sunshcmd \ 58241279Smarcel sysv \ 59241279Smarcel ternary \ 60241279Smarcel unexport \ 61241279Smarcel unexport-env \ 62292068Ssjg varcmd \ 63292068Ssjg varmisc \ 64292068Ssjg varshell 65241279Smarcel 66292068Ssjg# these tests were broken by referting POSIX chanegs 67292068SsjgSTRICT_POSIX_TESTS = \ 68292068Ssjg escape \ 69292068Ssjg impsrc \ 70292068Ssjg phony-end \ 71292068Ssjg posix1 \ 72292068Ssjg suffixes 73241279Smarcel 74292068Ssjg# Override make flags for certain tests 75241279Smarcelflags.doterror= 76243115Ssjgflags.order=-j1 77241279Smarcel 78292068SsjgOUTFILES= ${TESTNAMES:S/$/.out/} 79241279Smarcel 80292068Ssjgall: ${OUTFILES} 81292068Ssjg 82292068SsjgCLEANFILES += *.rawout *.out *.status *.tmp *.core *.tmp 83292068SsjgCLEANFILES += obj*.[och] lib*.a # posix1.mk 84292068SsjgCLEANFILES += issue* .[ab]* # suffixes.mk 85292068SsjgCLEANRECURSIVE += dir dummy # posix1.mk 86292068Ssjg 87241279Smarcelclean: 88292068Ssjg rm -f ${CLEANFILES} 89292068Ssjg.if !empty(CLEANRECURSIVE) 90292068Ssjg rm -rf ${CLEANRECURSIVE} 91292068Ssjg.endif 92241279Smarcel 93241279SmarcelTEST_MAKE?= ${.MAKE} 94241279SmarcelTOOL_SED?= sed 95241279SmarcelTOOL_TR?= tr 96241279SmarcelTOOL_DIFF?= diff 97241279SmarcelDIFF_FLAGS?= -u 98241279Smarcel 99246325Ssjg.if defined(.PARSEDIR) 100241279Smarcel# ensure consistent results from sort(1) 101241279SmarcelLC_ALL= C 102241279SmarcelLANG= C 103241279Smarcel.export LANG LC_ALL 104246325Ssjg.endif 105241279Smarcel 106292068Ssjg# some tests need extra post-processing 107292068SsjgSED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \ 108292068Ssjg -e '/command/s,No such.*,not found,' 109292068Ssjg 110292068Ssjg# the tests are actually done with sub-makes. 111292068Ssjg.SUFFIXES: .mk .rawout .out 112292068Ssjg.mk.rawout: 113292068Ssjg @echo ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} 114292068Ssjg -@cd ${.OBJDIR} && \ 115292068Ssjg { ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} \ 116292068Ssjg 2>&1 ; echo $$? >${.TARGET:R}.status ; } > ${.TARGET}.tmp 117292068Ssjg @mv ${.TARGET}.tmp ${.TARGET} 118292068Ssjg 119241279Smarcel# We always pretend .MAKE was called 'make' 120241279Smarcel# and strip ${.CURDIR}/ from the output 121241279Smarcel# and replace anything after 'stopped in' with unit-tests 122241279Smarcel# so the results can be compared. 123292068Ssjg.rawout.out: 124292068Ssjg @echo postprocess ${.TARGET} 125292068Ssjg @${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[][0-9]*:,make:,' \ 126292068Ssjg -e 's,${TEST_MAKE:C/\./\\\./g},make,' \ 127292068Ssjg -e '/stopped/s, /.*, unit-tests,' \ 128292068Ssjg -e 's,${.CURDIR:C/\./\\\./g}/,,g' \ 129292068Ssjg -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' ${SED_CMDS.${.TARGET:T:R}} \ 130292068Ssjg < ${.IMPSRC} > ${.TARGET}.tmp 131292068Ssjg @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp 132292068Ssjg @mv ${.TARGET}.tmp ${.TARGET} 133241279Smarcel 134292068Ssjg# Compare all output files 135292068Ssjgtest: ${OUTFILES} .PHONY 136292068Ssjg @failed= ; \ 137292068Ssjg for test in ${TESTNAMES}; do \ 138292068Ssjg ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \ 139292068Ssjg || failed="$${failed}$${failed:+ }$${test}" ; \ 140292068Ssjg done ; \ 141292068Ssjg if [ -n "$${failed}" ]; then \ 142292068Ssjg echo "Failed tests: $${failed}" ; false ; \ 143292068Ssjg else \ 144292068Ssjg echo "All tests passed" ; \ 145292068Ssjg fi 146292068Ssjg 147241279Smarcelaccept: 148292068Ssjg @for test in ${TESTNAMES}; do \ 149292068Ssjg cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \ 150292068Ssjg || { echo "Replacing $${test}.exp" ; \ 151292068Ssjg cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \ 152292068Ssjg done 153241279Smarcel 154292068Ssjg.if exists(${TEST_MAKE}) 155292068Ssjg${TESTNAMES:S/$/.rawout/}: ${TEST_MAKE} 156292068Ssjg.endif 157292068Ssjg 158292068Ssjg.sinclude <bsd.obj.mk> 159