1# This is a generated file, do NOT edit! 2# See contrib/bmake/bsd.after-import.mk 3# 4# $FreeBSD$ 5 6SRCTOP?= ${.CURDIR:H:H:H} 7 8# $Id: Makefile.in,v 1.47 2015/05/05 21:58:06 sjg Exp $ 9# 10# $NetBSD: Makefile,v 1.52 2015/05/05 21:51:09 sjg Exp $ 11# 12# Unit tests for make(1) 13# The main targets are: 14# 15# all: run all the tests 16# test: run 'all', and compare to expected results 17# accept: move generated output to expected results 18# 19# Adding a test case. 20# Each feature should get its own set of tests in its own suitably 21# named makefile (*.mk), with its own set of expected results (*.exp), 22# and it should be added to the TESTNAMES list. 23# 24 25srcdir= ${SRCTOP}/contrib/bmake/unit-tests 26 27.MAIN: all 28 29UNIT_TESTS:= ${srcdir} 30.PATH: ${UNIT_TESTS} 31 32# Each test is in a sub-makefile. 33# Keep the list sorted. 34TESTNAMES= \ 35 comment \ 36 cond1 \ 37 cond2 \ 38 error \ 39 export \ 40 export-all \ 41 export-env \ 42 doterror \ 43 dotwait \ 44 forloop \ 45 forsubst \ 46 hash \ 47 misc \ 48 moderrs \ 49 modmatch \ 50 modmisc \ 51 modorder \ 52 modts \ 53 modword \ 54 order \ 55 posix \ 56 qequals \ 57 sunshcmd \ 58 sysv \ 59 ternary \ 60 unexport \ 61 unexport-env \ 62 varcmd \ 63 varmisc \ 64 varshell 65 66# these tests were broken by referting POSIX chanegs 67STRICT_POSIX_TESTS = \ 68 escape \ 69 impsrc \ 70 phony-end \ 71 posix1 \ 72 suffixes 73 74# Override make flags for certain tests 75flags.doterror= 76flags.order=-j1 77 78OUTFILES= ${TESTNAMES:S/$/.out/} 79 80all: ${OUTFILES} 81 82CLEANFILES += *.rawout *.out *.status *.tmp *.core *.tmp 83CLEANFILES += obj*.[och] lib*.a # posix1.mk 84CLEANFILES += issue* .[ab]* # suffixes.mk 85CLEANRECURSIVE += dir dummy # posix1.mk 86 87clean: 88 rm -f ${CLEANFILES} 89.if !empty(CLEANRECURSIVE) 90 rm -rf ${CLEANRECURSIVE} 91.endif 92 93TEST_MAKE?= ${.MAKE} 94TOOL_SED?= sed 95TOOL_TR?= tr 96TOOL_DIFF?= diff 97DIFF_FLAGS?= -u 98 99.if defined(.PARSEDIR) 100# ensure consistent results from sort(1) 101LC_ALL= C 102LANG= C 103.export LANG LC_ALL 104.endif 105 106# some tests need extra post-processing 107SED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \ 108 -e '/command/s,No such.*,not found,' 109 110# the tests are actually done with sub-makes. 111.SUFFIXES: .mk .rawout .out 112.mk.rawout: 113 @echo ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} 114 -@cd ${.OBJDIR} && \ 115 { ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} \ 116 2>&1 ; echo $$? >${.TARGET:R}.status ; } > ${.TARGET}.tmp 117 @mv ${.TARGET}.tmp ${.TARGET} 118 119# We always pretend .MAKE was called 'make' 120# and strip ${.CURDIR}/ from the output 121# and replace anything after 'stopped in' with unit-tests 122# so the results can be compared. 123.rawout.out: 124 @echo postprocess ${.TARGET} 125 @${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[][0-9]*:,make:,' \ 126 -e 's,${TEST_MAKE:C/\./\\\./g},make,' \ 127 -e '/stopped/s, /.*, unit-tests,' \ 128 -e 's,${.CURDIR:C/\./\\\./g}/,,g' \ 129 -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' ${SED_CMDS.${.TARGET:T:R}} \ 130 < ${.IMPSRC} > ${.TARGET}.tmp 131 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp 132 @mv ${.TARGET}.tmp ${.TARGET} 133 134# Compare all output files 135test: ${OUTFILES} .PHONY 136 @failed= ; \ 137 for test in ${TESTNAMES}; do \ 138 ${TOOL_DIFF} -u ${UNIT_TESTS}/$${test}.exp $${test}.out \ 139 || failed="$${failed}$${failed:+ }$${test}" ; \ 140 done ; \ 141 if [ -n "$${failed}" ]; then \ 142 echo "Failed tests: $${failed}" ; false ; \ 143 else \ 144 echo "All tests passed" ; \ 145 fi 146 147accept: 148 @for test in ${TESTNAMES}; do \ 149 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \ 150 || { echo "Replacing $${test}.exp" ; \ 151 cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \ 152 done 153 154.if exists(${TEST_MAKE}) 155${TESTNAMES:S/$/.rawout/}: ${TEST_MAKE} 156.endif 157 158.sinclude <bsd.obj.mk> 159