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 8291978Ssjg# $Id: Makefile.in,v 1.48 2015/12/07 04:06:29 sjg Exp $ 9241279Smarcel# 10282740Ssjg# $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 16281812Ssjg# 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 21281812Ssjg# named makefile (*.mk), with its own set of expected results (*.exp), 22281812Ssjg# 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} 30281812Ssjg.PATH: ${UNIT_TESTS} 31241279Smarcel 32281812Ssjg# Each test is in a sub-makefile. 33281812Ssjg# Keep the list sorted. 34281812SsjgTESTNAMES= \ 35241279Smarcel comment \ 36241279Smarcel cond1 \ 37282740Ssjg 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 \ 62281812Ssjg varcmd \ 63281812Ssjg varmisc \ 64281812Ssjg varshell 65241279Smarcel 66281812Ssjg# these tests were broken by referting POSIX chanegs 67281812SsjgSTRICT_POSIX_TESTS = \ 68281812Ssjg escape \ 69281812Ssjg impsrc \ 70281812Ssjg phony-end \ 71281812Ssjg posix1 \ 72281812Ssjg suffixes 73241279Smarcel 74281812Ssjg# Override make flags for certain tests 75241279Smarcelflags.doterror= 76243115Ssjgflags.order=-j1 77241279Smarcel 78281812SsjgOUTFILES= ${TESTNAMES:S/$/.out/} 79241279Smarcel 80281812Ssjgall: ${OUTFILES} 81281812Ssjg 82281812SsjgCLEANFILES += *.rawout *.out *.status *.tmp *.core *.tmp 83281812SsjgCLEANFILES += obj*.[och] lib*.a # posix1.mk 84281812SsjgCLEANFILES += issue* .[ab]* # suffixes.mk 85281812SsjgCLEANRECURSIVE += dir dummy # posix1.mk 86281812Ssjg 87241279Smarcelclean: 88281812Ssjg rm -f ${CLEANFILES} 89281812Ssjg.if !empty(CLEANRECURSIVE) 90281812Ssjg rm -rf ${CLEANRECURSIVE} 91281812Ssjg.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 106281812Ssjg# some tests need extra post-processing 107281812SsjgSED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \ 108281812Ssjg -e '/command/s,No such.*,not found,' 109281812Ssjg 110281812Ssjg# the tests are actually done with sub-makes. 111281812Ssjg.SUFFIXES: .mk .rawout .out 112281812Ssjg.mk.rawout: 113281812Ssjg @echo ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} 114281812Ssjg -@cd ${.OBJDIR} && \ 115281812Ssjg { ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} \ 116281812Ssjg 2>&1 ; echo $$? >${.TARGET:R}.status ; } > ${.TARGET}.tmp 117281812Ssjg @mv ${.TARGET}.tmp ${.TARGET} 118281812Ssjg 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. 123281812Ssjg.rawout.out: 124281812Ssjg @echo postprocess ${.TARGET} 125281812Ssjg @${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[][0-9]*:,make:,' \ 126281812Ssjg -e 's,${TEST_MAKE:C/\./\\\./g},make,' \ 127281812Ssjg -e '/stopped/s, /.*, unit-tests,' \ 128281812Ssjg -e 's,${.CURDIR:C/\./\\\./g}/,,g' \ 129281812Ssjg -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' ${SED_CMDS.${.TARGET:T:R}} \ 130281812Ssjg < ${.IMPSRC} > ${.TARGET}.tmp 131281812Ssjg @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp 132281812Ssjg @mv ${.TARGET}.tmp ${.TARGET} 133241279Smarcel 134281812Ssjg# Compare all output files 135281812Ssjgtest: ${OUTFILES} .PHONY 136281812Ssjg @failed= ; \ 137281812Ssjg for test in ${TESTNAMES}; do \ 138291978Ssjg ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \ 139281812Ssjg || failed="$${failed}$${failed:+ }$${test}" ; \ 140281812Ssjg done ; \ 141281812Ssjg if [ -n "$${failed}" ]; then \ 142281812Ssjg echo "Failed tests: $${failed}" ; false ; \ 143281812Ssjg else \ 144281812Ssjg echo "All tests passed" ; \ 145281812Ssjg fi 146281812Ssjg 147241279Smarcelaccept: 148281812Ssjg @for test in ${TESTNAMES}; do \ 149281812Ssjg cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \ 150281812Ssjg || { echo "Replacing $${test}.exp" ; \ 151281812Ssjg cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \ 152281812Ssjg done 153241279Smarcel 154281812Ssjg.if exists(${TEST_MAKE}) 155281812Ssjg${TESTNAMES:S/$/.rawout/}: ${TEST_MAKE} 156281812Ssjg.endif 157281812Ssjg 158281812Ssjg.sinclude <bsd.obj.mk> 159