aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake/unit-tests/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bmake/unit-tests/Makefile')
-rw-r--r--contrib/bmake/unit-tests/Makefile252
1 files changed, 175 insertions, 77 deletions
diff --git a/contrib/bmake/unit-tests/Makefile b/contrib/bmake/unit-tests/Makefile
index c3b64abad84a..f6c298679a62 100644
--- a/contrib/bmake/unit-tests/Makefile
+++ b/contrib/bmake/unit-tests/Makefile
@@ -1,6 +1,6 @@
-# $Id: Makefile,v 1.180 2022/04/18 21:25:37 sjg Exp $
+# $Id: Makefile,v 1.245 2025/08/05 16:18:07 sjg Exp $
#
-# $NetBSD: Makefile,v 1.312 2022/04/18 15:06:28 rillig Exp $
+# $NetBSD: Makefile,v 1.372 2025/08/04 22:44:49 sjg Exp $
#
# Unit tests for make(1)
#
@@ -25,10 +25,6 @@
# named makefile (*.mk), with its own set of expected results (*.exp),
# and it should be added to the TESTS list.
#
-# A few *.mk files are helper files for other tests (such as include-sub.mk)
-# and are thus not added to TESTS. Such files must be ignored in
-# src/tests/usr.bin/make/t_make.sh.
-#
.MAIN: all
@@ -36,12 +32,33 @@
.MAKE.OS?= ${uname -s:L:sh}
.MAKE.UID?= ${id -u:L:sh}
+# for many tests we need a TMPDIR that will not collide
+# with other users.
+.if ${.OBJDIR} != ${.CURDIR}
+# easy
+TMPDIR:= ${.OBJDIR}/tmp
+.elif defined(TMPDIR)
+TMPDIR:= ${TMPDIR}/uid${.MAKE.UID}
+.else
+TMPDIR:= /tmp/uid${.MAKE.UID}
+.endif
+# make sure it exists
+.if !exist(${TMPDIR})
+_!= mkdir -p ${TMPDIR}
+.endif
+# and clean it up - outside the context of
+# any target that might be using it.
+.END: rm-tmpdir
+rm-tmpdir: .NOMETA
+ @rm -rf ${TMPDIR}
+
# Each test is in a sub-makefile.
# Keep the list sorted.
# Any test that is commented out must be ignored in
# src/tests/usr.bin/make/t_make.sh as well.
#TESTS+= archive
#TESTS+= archive-suffix
+TESTS+= char-005c-reverse-solidus
TESTS+= cmd-errors
TESTS+= cmd-errors-jobs
TESTS+= cmd-errors-lint
@@ -83,7 +100,6 @@ TESTS+= cond-token-plain
TESTS+= cond-token-string
TESTS+= cond-token-var
TESTS+= cond-undef-lint
-TESTS+= cond1
TESTS+= counter
TESTS+= counter-append
TESTS+= dep
@@ -168,6 +184,8 @@ TESTS+= directive-export-impl
TESTS+= directive-export-gmake
TESTS+= directive-export-literal
TESTS+= directive-for
+TESTS+= directive-for-break
+TESTS+= directive-for-empty
TESTS+= directive-for-errors
TESTS+= directive-for-escape
TESTS+= directive-for-generating-endif
@@ -183,6 +201,7 @@ TESTS+= directive-ifndef
TESTS+= directive-ifnmake
TESTS+= directive-include
TESTS+= directive-include-fatal
+TESTS+= directive-include-guard
TESTS+= directive-info
TESTS+= directive-misspellings
TESTS+= directive-sinclude
@@ -199,14 +218,13 @@ TESTS+= export
TESTS+= export-all
TESTS+= export-env
TESTS+= export-variants
-TESTS+= forloop
-TESTS+= forsubst
TESTS+= gnode-submake
TESTS+= hanoi-include
TESTS+= impsrc
TESTS+= include-main
TESTS+= job-flags
-#TESTS+= job-output-long-lines
+TESTS+= job-output
+TESTS+= job-output-long-lines
TESTS+= job-output-null
TESTS+= jobs-empty-commands
TESTS+= jobs-empty-commands-error
@@ -216,8 +234,8 @@ TESTS+= jobs-error-nested-make
TESTS+= lint
TESTS+= make-exported
TESTS+= meta-cmd-cmp
+TESTS+= meta-output
TESTS+= moderrs
-TESTS+= modmatch
TESTS+= modmisc
.if ${.MAKE.UID} > 0
TESTS+= objdir-writable
@@ -239,7 +257,7 @@ TESTS+= opt-debug-graph1
TESTS+= opt-debug-graph2
TESTS+= opt-debug-graph3
TESTS+= opt-debug-hash
-#TESTS+= opt-debug-jobs
+TESTS+= opt-debug-jobs
TESTS+= opt-debug-lint
TESTS+= opt-debug-loud
TESTS+= opt-debug-meta
@@ -284,6 +302,9 @@ TESTS+= parse
TESTS+= parse-var
TESTS+= phony-end
TESTS+= posix
+TESTS+= posix-execution
+TESTS+= posix-expansion
+TESTS+= posix-varassign
TESTS+= # posix1 # broken by reverting POSIX changes
TESTS+= recursive
TESTS+= sh
@@ -304,6 +325,7 @@ TESTS+= shell-custom
TESTS+= shell-ksh
.endif
TESTS+= shell-sh
+TESTS+= suff
TESTS+= suff-add-later
TESTS+= suff-clear-regular
TESTS+= suff-clear-single
@@ -324,6 +346,7 @@ TESTS+= ternary
TESTS+= unexport
TESTS+= unexport-env
TESTS+= use-inference
+TESTS+= var-readonly
TESTS+= var-scope
TESTS+= var-scope-cmdline
TESTS+= var-scope-env
@@ -362,6 +385,7 @@ TESTS+= varmod-loop-delete
TESTS+= varmod-loop-varname
TESTS+= varmod-match
TESTS+= varmod-match-escape
+TESTS+= varmod-mtime
TESTS+= varmod-no-match
TESTS+= varmod-order
TESTS+= varmod-order-numeric
@@ -386,10 +410,12 @@ TESTS+= varmod-to-lower
TESTS+= varmod-to-many-words
TESTS+= varmod-to-one-word
TESTS+= varmod-to-separator
+TESTS+= varmod-to-title
TESTS+= varmod-to-upper
TESTS+= varmod-undefined
TESTS+= varmod-unique
TESTS+= varname
+TESTS+= varname-circumflex
TESTS+= varname-dollar
TESTS+= varname-dot-alltargets
TESTS+= varname-dot-curdir
@@ -408,12 +434,20 @@ TESTS+= varname-dot-make-makefiles
TESTS+= varname-dot-make-meta-bailiwick
TESTS+= varname-dot-make-meta-created
TESTS+= varname-dot-make-meta-files
+.if ${.MAKE.PATH_FILEMON:Uno:Nktrace:N/dev*} == "" && ${TMPDIR:N/tmp*:N/var/tmp*} != ""
+# these tests will not work if TMPDIR is or is a subdir of
+# /tmp or /var/tmp
+.if ${.MAKE.PATH_FILEMON:N/dev/*} != "" || exists(${.MAKE.PATH_FILEMON})
TESTS+= varname-dot-make-meta-ignore_filter
TESTS+= varname-dot-make-meta-ignore_paths
TESTS+= varname-dot-make-meta-ignore_patterns
+TESTS+= varname-dot-make-path_filemon
+.else
+.warning Skipping tests that require ${.MAKE.PATH_FILEMON}
+.endif
+.endif
TESTS+= varname-dot-make-meta-prefix
TESTS+= varname-dot-make-mode
-TESTS+= varname-dot-make-path_filemon
TESTS+= varname-dot-make-pid
TESTS+= varname-dot-make-ppid
TESTS+= varname-dot-make-save_dollars
@@ -429,6 +463,7 @@ TESTS+= varname-dot-suffixes
TESTS+= varname-dot-targets
TESTS+= varname-empty
TESTS+= varname-make
+TESTS+= varname-make_stack_trace
TESTS+= varname-make_print_var_on_error
TESTS+= varname-make_print_var_on_error-jobs
TESTS+= varname-makefile
@@ -439,21 +474,51 @@ TESTS+= varparse-dynamic
TESTS+= varparse-errors
TESTS+= varparse-mod
TESTS+= varparse-undef-partial
-TESTS+= varquote
# some shells have quirks
_shell := ${.SHELL:tA:T}
.if ${_shell} == "dash"
# dash fails -x output
BROKEN_TESTS+= opt-debug-x-trace
-.elif ${_shell} == "ksh"
-BROKEN_TESTS+= sh-flags
+.elif ${_shell:N*ksh*} == ""
+BROKEN_TESTS+= \
+ deptgt-silent-jobs \
+ job-flags \
+ job-output-long-lines \
+ opt-debug-x-trace \
+ sh-flags \
+ var-op-shell \
+
+.if ${_shell:Nmksh} == ""
+# more broken that pdksh
+BROKEN_TESTS+= \
+ opt-jobs-no-action \
+ sh-errctl \
+ sh-leading-hyphen \
+
+.endif
+.endif
+
+.if ${UTC_1:Uno} == ""
+# this will not work if UTC_1 is set empty
+BROKEN_TESTS+= varmod-localtime
.endif
.if ${.MAKE.OS:NDarwin} == ""
BROKEN_TESTS+= shell-ksh
.endif
+.if ${.MAKE.OS:NIRIX*} == ""
+BROKEN_TESTS+= \
+ cmd-interrupt \
+ deptgt-interrupt \
+ job-output-null \
+ opt-chdir \
+ opt-debug-x-trace \
+ sh-leading-hyphen \
+
+.endif
+
.if ${.MAKE.OS} == "SCO_SV"
BROKEN_TESTS+= \
opt-debug-graph[23] \
@@ -479,7 +544,6 @@ TESTS:= ${TESTS:${BROKEN_TESTS:S,^,N,:ts:}}
# Ideas for more tests:
# char-0020-space.mk
-# char-005C-backslash.mk
# escape-cond-str.mk
# escape-cond-func-arg.mk
# escape-varmod.mk
@@ -501,7 +565,8 @@ TESTS:= ${TESTS:${BROKEN_TESTS:S,^,N,:ts:}}
ENV.depsrc-optional+= TZ=UTC
ENV.deptgt-phony+= MAKESYSPATH=.
ENV.directive-undef= ENV_VAR=env-value
-ENV.envfirst= FROM_ENV=value-from-env
+ENV.opt-env= FROM_ENV=value-from-env
+ENV.opt-m-include-dir= ${MAKEOBJDIR:DMAKEOBJDIR=${MAKEOBJDIR}}
ENV.varmisc= FROM_ENV=env
ENV.varmisc+= FROM_ENV_BEFORE=env
ENV.varmisc+= FROM_ENV_AFTER=env
@@ -521,7 +586,17 @@ FLAGS.varname-empty= -dv '$${:U}=cmdline-u' '=cmdline-plain'
# Some tests need extra postprocessing.
SED_CMDS.deptgt-phony= ${STD_SED_CMDS.dd}
SED_CMDS.dir= ${STD_SED_CMDS.dd}
+SED_CMDS.directive-include-guard= \
+ -e '/\.MAKEFLAGS/d' \
+ -e '/^Parsing .*:[1-9][0-9]*:/d' \
+ -e '/^SetFilenameVars:/d' \
+ -e '/^ParseDependency/d' \
+ -e '/^ParseEOF:/d'
SED_CMDS.export= -e '/^[^=_A-Za-z0-9]*=/d'
+SED_CMDS.export+= -e '/^DIFF/d'
+.if ${.MAKE.OS:NCygwin} == ""
+SED_CMDS.export+= -e '/^WINDIR=/d' -e '/^SYSTEMROOT=/d'
+.endif
SED_CMDS.export-all= ${SED_CMDS.export}
SED_CMDS.export-env= ${SED_CMDS.export}
SED_CMDS.cmdline= -e 's,uid${.MAKE.UID}/,,'
@@ -540,17 +615,16 @@ SED_CMDS.opt-chdir= -e 's,\(nonexistent\).[1-9][0-9]*,\1,' \
-e '/name/s,file,File,' \
-e 's,no such,No such,' \
-e 's,Filename,File name,'
+
+# meta line numbers can vary based on filemon implementation
+SED_CMDS.meta-ignore= -e 's,\(\.meta:\)[1-9][0-9]*:,\1<line>:,'
+
+SED_CMDS.opt-chdir= -e 's,\(nonexistent\).[1-9][0-9]*,\1,'
SED_CMDS.opt-debug-graph1= ${STD_SED_CMDS.dg1}
SED_CMDS.opt-debug-graph2= ${STD_SED_CMDS.dg2}
SED_CMDS.opt-debug-graph3= ${STD_SED_CMDS.dg3}
-SED_CMDS.opt-debug-hash= -e 's,\(numEntries\)=[1-9][0-9],\1=<entries>,'
-SED_CMDS.opt-debug-jobs= -e 's,([0-9][0-9]*),(<pid>),'
-SED_CMDS.opt-debug-jobs+= -e 's,pid [0-9][0-9]*,pid <pid>,'
-SED_CMDS.opt-debug-jobs+= -e 's,Process [0-9][0-9]*,Process <pid>,'
-SED_CMDS.opt-debug-jobs+= -e 's,JobFinish: [0-9][0-9]*,JobFinish: <pid>,'
-SED_CMDS.opt-debug-jobs+= -e 's,Command: ${.SHELL:T},Command: <shell>,'
-# The "-q" may be there or not, see jobs.c, variable shells.
-SED_CMDS.opt-debug-jobs+= -e 's,^\(.Command: <shell>\) -q,\1,'
+SED_CMDS.opt-debug-hash= -e 's,\(entries\)=[1-9][0-9],\1=<entries>,'
+SED_CMDS.opt-debug-jobs= ${STD_SED_CMDS.dj}
SED_CMDS.opt-debug-lint+= ${STD_SED_CMDS.regex}
SED_CMDS.opt-jobs-no-action= ${STD_SED_CMDS.hide-from-output}
SED_CMDS.opt-no-action-runflags= ${STD_SED_CMDS.hide-from-output}
@@ -558,11 +632,15 @@ SED_CMDS.opt-where-am-i= -e '/usr.obj/d'
# For Compat_RunCommand, useShell == false.
SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<not found: ...>,'
# For Compat_RunCommand, useShell == true.
-SED_CMDS.sh-dots+= -e 's,^make: exec(\(.*\)) failed (.*)$$,<not found: \1>,'
+SED_CMDS.sh-dots+= -e 's,^make: exec(\(.*\)): .*$$,<not found: \1>,'
SED_CMDS.sh-dots+= -e 's,^\(\*\*\* Error code \)[1-9][0-9]*,\1<nonzero>,'
+# Race condition between the child's stdout and make's status.
SED_CMDS.sh-errctl= ${STD_SED_CMDS.dj}
+SED_CMDS.sh-errctl+= -e '/^Process with pid/d'
+SED_CMDS.sh-errctl+= -e '/^JobFinish:/d'
SED_CMDS.sh-flags= ${STD_SED_CMDS.hide-from-output}
SED_CMDS.shell-csh= ${STD_SED_CMDS.white-space}
+SED_CMDS.sh-leading-hyphen= ${STD_SED_CMDS.shell}
SED_CMDS.suff-main+= ${STD_SED_CMDS.dg1}
SED_CMDS.suff-main-several+= ${STD_SED_CMDS.dg1}
SED_CMDS.suff-transform-debug+= ${STD_SED_CMDS.dg1}
@@ -570,17 +648,24 @@ SED_CMDS.var-op-shell+= ${STD_SED_CMDS.shell}
SED_CMDS.var-op-shell+= -e '/command/s,No such.*,not found,'
SED_CMDS.var-op-shell+= ${STD_SED_CMDS.white-space}
SED_CMDS.vardebug+= -e 's,${.SHELL},</path/to/shell>,'
+SED_CMDS.varmod-mtime+= -e "s,\(mtime for .*\): .*,\1: <ENOENT>,"
SED_CMDS.varmod-subst-regex+= ${STD_SED_CMDS.regex}
-SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
-SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
+SED_CMDS.varparse-errors+= ${STD_SED_CMDS.timestamp}
+SED_CMDS.varname-dot-make-meta-ignore_filter+= ${SED_CMDS.meta-ignore}
+SED_CMDS.varname-dot-make-meta-ignore_paths+= ${SED_CMDS.meta-ignore}
+SED_CMDS.varname-dot-make-meta-ignore_patterns+= ${SED_CMDS.meta-ignore}
+SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: [^:]*:,make: <normalized>:,'
+SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: [^:]*:,make: <normalized>:,'
SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g'
SED_CMDS.varname-dot-shell+= -e 's,"/[^" ]*","(details omitted)",g'
SED_CMDS.varname-dot-shell+= -e 's,\[/[^] ]*\],[(details omitted)],g'
-SED_CMDS.varname-empty= ${.OBJDIR .PARSEDIR .PATH .SHELL:L:@v@-e '/\\$v/d'@}
+SED_CMDS.varname-empty= ${.OBJDIR .PARSEDIR .PATH .SHELL .SYSPATH:L:@v@-e '/\\$v/d'@}
# Some tests need an additional round of postprocessing.
+POSTPROC.depsrc-wait= sed -e '/^---/d' -e 's,^\(: Making 3[abc]\)[123]$$,\1,'
POSTPROC.deptgt-suffixes= awk '/^\#\*\*\* Suffixes/,/^never-stop/'
-POSTPROC.gnode-submake= awk '/Input graph/, /^$$/'
+POSTPROC.gnode-submake= awk '/Begin input graph/, /^$$/'
+POSTPROC.varname-dot-make-mode= sed 's,^\(: Making [abc]\)[123]$$,\1,'
# Some tests reuse other tests, which makes them unnecessarily fragile.
export-all.rawout: export.mk
@@ -593,31 +678,32 @@ unexport-env.rawout: export.mk
# In tests that use the debugging option -dd, ignore debugging output that is
# only logged in -DCLEANUP mode.
-STD_SED_CMDS.dd= -e '/^OpenDirs_Done:/d'
-STD_SED_CMDS.dd+= -e '/^CachedDir /d'
+STD_SED_CMDS.dd= -e '/^OpenDirs_Done:/d'
+STD_SED_CMDS.dd+= -e '/^CachedDir /d'
+STD_SED_CMDS.dd+= -e 's, ${DEFSYSPATH:U/usr/share/mk} , <defsyspath> ,'
# Omit details such as process IDs from the output of the -dg1 option.
STD_SED_CMDS.dg1= -e '/\#.* \.$$/d'
STD_SED_CMDS.dg1+= -e '/\.MAKE.PATH_FILEMON/d'
-STD_SED_CMDS.dg1+= -e '/^MAKE_VERSION/d;/^\#.*\/mk/d'
+STD_SED_CMDS.dg1+= -e '/^\#.*\/mk/d'
STD_SED_CMDS.dg1+= -e 's, ${DEFSYSPATH:U/usr/share/mk}$$, <defsyspath>,'
STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE *=\) .*,\1 <details omitted>,'
STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.[A-Z_]* *=\) .*,\1 <details omitted>,'
+STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.JOBS\.C *=\) .*,\1 <details omitted>,'
STD_SED_CMDS.dg1+= -e 's,^\(MACHINE[_ARCH]* *=\) .*,\1 <details omitted>,'
STD_SED_CMDS.dg1+= -e 's,^\(MAKE *=\) .*,\1 <details omitted>,'
STD_SED_CMDS.dg1+= -e 's,^\(\.SHELL *=\) .*,\1 <details omitted>,'
+STD_SED_CMDS.dg1+= -e '/\.SYSPATH/d'
STD_SED_CMDS.dg2= ${STD_SED_CMDS.dg1}
STD_SED_CMDS.dg2+= -e 's,\(last modified\) ..:..:.. ... ..\, ....,\1 <timestamp>,'
STD_SED_CMDS.dg3= ${STD_SED_CMDS.dg2}
# Omit details such as process IDs from the output of the -dj option.
-STD_SED_CMDS.dj= \
- -e '/Process/d;/JobFinish:/d' \
- -e 's,^\(Job_TokenWithdraw\)([0-9]*),\1(<pid>),' \
- -e 's,^([0-9][0-9]*) \(withdrew token\),(<pid>) \1,' \
- -e 's, \(pid\) [0-9][0-9]*, \1 <pid>,' \
- -e 's,^\( Command:\) .*,\1 <shell>,'
+STD_SED_CMDS.dj= -e 's, pid [0-9][0-9]*, pid <pid>,'
+STD_SED_CMDS.dj+= -e 's,^\(.Command\): ${.SHELL:T},\1: <shell>,'
+# The "-q" may be there or not, see jobs.c, variable shells.
+STD_SED_CMDS.dj+= -e 's,^\(.Command: <shell>\) -q,\1,'
# Reduce the noise for tests running with the -n option, since there is no
# other way to suppress the echoing of the commands.
@@ -649,9 +735,11 @@ STD_SED_CMDS.hide-from-output= \
# bash 5.1.0 bash: line 1: /nonexistent: No such file or directory
# dash dash: 1: cannot open /nonexistent: No such file
#
+STD_SED_CMDS.shell+= -e 's,^${.SHELL},${.SHELL:T},'
STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: line [0-9][0-9]*: ,,'
STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: [0-9][0-9]*: ,,'
STD_SED_CMDS.shell+= -e 's,^${.SHELL:T}: ,,'
+STD_SED_CMDS.shell+= -e 's,: command not found,: not found,'
STD_SED_CMDS.white-space= -e 's, *, ,g' -e 's, *$$,,'
@@ -660,6 +748,11 @@ STD_SED_CMDS.white-space= -e 's, *, ,g' -e 's, *$$,,'
STD_SED_CMDS.regex= \
-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
+# Normalize timestamps from ':gmtime' or ':localtime' to '<timestamp>'.
+# See STD_SED_CMDS.dg2 for timestamps from the debug log.
+STD_SED_CMDS.timestamp= \
+ -e 's,[A-Z][a-z][a-z] [A-Z][a-z][a-z] [ 0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [12][0-9][0-9][0-9],<timestamp>,'
+
# End of the configuration helpers section.
.-include "Makefile.inc"
@@ -679,11 +772,11 @@ all: ${OUTFILES}
CLEANFILES= *.rawout *.out *.status *.tmp *.core *.tmp
CLEANFILES+= obj*.[och] lib*.a # posix1.mk
CLEANFILES+= issue* .[ab]* # suffixes.mk
-CLEANDIRS= dir dummy # posix1.mk
+CLEANDIRS= dir dummy *.tmp # posix1.mk
clean:
- rm -f ${CLEANFILES}
rm -rf ${CLEANDIRS}
+ rm -f ${CLEANFILES}
TEST_MAKE?= ${.MAKE}
TOOL_SED?= sed
@@ -691,40 +784,33 @@ TOOL_TR?= tr
TOOL_DIFF?= diff
DIFF_FLAGS?= -u
-.if defined(.PARSEDIR)
# ensure consistent results from sort(1)
LC_ALL= C
LANG= C
.export LANG LC_ALL
-.endif
.if ${.MAKE.MODE:Unormal:Mmeta} != ""
# we don't need the noise
_MKMSG_TEST= :
.endif
-
-# for many tests we need a TMPDIR that will not collide
-# with other users.
-.if ${.OBJDIR} != ${.CURDIR}
-# easy
-TMPDIR:= ${.OBJDIR}/tmp
-.elif defined(TMPDIR)
-TMPDIR:= ${TMPDIR}/uid${.MAKE.UID}
-.else
-TMPDIR:= /tmp/uid${.MAKE.UID}
+# Some Linux systems such as Fedora have deprecated egrep in favor of grep -E.
+.if ${.MAKE.OS:NLinux} == ""
+EGREP= grep -E
.endif
-# make sure it exists
-.if !exist(${TMPDIR})
-_!= mkdir -p ${TMPDIR}
-.endif
-
-MAKE_TEST_ENV= MALLOC_OPTIONS="JA" # for jemalloc 100
+# Keep the classical definition for all other systems. Just as the bmake code
+# is kept compatible with C90, the tests are kept compatible with systems that
+# are several decades old and don't follow modern POSIX standards.
+EGREP?= egrep
+
+MAKE_TEST_ENV= EGREP="${EGREP}"
+MAKE_TEST_ENV+= DIFF="${TOOL_DIFF}" DIFF_FLAGS="${DIFF_FLAGS}"
+MAKE_TEST_ENV+= MALLOC_OPTIONS="JA" # for jemalloc 100
MAKE_TEST_ENV+= MALLOC_CONF="junk:true" # for jemalloc 510
MAKE_TEST_ENV+= TMPDIR=${TMPDIR}
.if ${.MAKE.OS} == "NetBSD"
-LIMIT_RESOURCES?= ulimit -v 200000
+LIMIT_RESOURCES?= ulimit -v 300000
.endif
LIMIT_RESOURCES?= :
@@ -746,42 +832,49 @@ LIMIT_RESOURCES?= :
echo $$status > ${.TARGET:R}.status
@mv ${.TARGET}.tmp ${.TARGET}
-# Postprocess the test output so that the results can be compared.
+# Postprocess the test output to make the output platform-independent.
#
-# always pretend .MAKE was called 'make'
-_SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'
-_SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,'
-_SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,'
-# replace anything after 'stopped in' with unit-tests
-_SED_CMDS+= -e '/stopped/s, /.*, unit-tests,'
+# Replace anything after 'stopped in' with unit-tests
+_SED_CMDS+= -e '/stopped/s, in /.*, in unit-tests,'
# Allow the test files to be placed anywhere.
_SED_CMDS+= -e 's,\(\.PARSEDIR}\) = `'"/[^']*'"',\1 = <some-dir>,'
_SED_CMDS+= -e 's,\(\.INCLUDEDFROMDIR}\) = `'"/[^']*'"',\1 = <some-dir>,'
-_SED_CMDS+= -e 's,${TMPDIR},<tmpdir>,g'
+_SED_CMDS+= -e 's,${TMPDIR},<tmpdir>,g' -e 's,${TMPDIR:tA},<tmpdir>,g'
# canonicalize ${.OBJDIR} and ${.CURDIR}
+_SED_CMDS+= -e 's,${.CURDIR},<curdir>,g'
.if ${.OBJDIR} != ${.CURDIR}
# yes this is inaccurate but none of the tests expect <objdir> anywhere
# which we get depending on how MAKEOBJDIR is set.
-_SED_CMDS+= -e 's,${.OBJDIR},<curdir>,g'
+_SED_CMDS+= -e 's,${.OBJDIR},<curdir>,g' -e 's,${.OBJDIR:tA},<curdir>,g'
.endif
-_SED_CMDS+= -e 's,${.CURDIR},<curdir>,g'
+# always pretend .MAKE was called 'make'
+_SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'
+_SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,'
+_SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,'
+_SED_CMDS+= -e 's,${TEST_MAKE:T:S,.,\\.,g}\(\[[1-9][0-9]*\][: ]\),make\1,'
_SED_CMDS+= -e 's,<curdir>/,,g'
_SED_CMDS+= -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
+_SED_CMDS+= -e '/MAKE_VERSION/d'
+_SED_CMDS+= -e '/EGREP=/d'
+
# on AT&T derived systems: false exits 255 not 1
.if ${.MAKE.OS:N*BSD} != ""
_SED_CMDS+= -e 's,\(Error code\) 255,\1 1,'
.endif
-.if ${.SHELL:T} == "ksh"
+.if ${_shell:N*ksh*} == ""
_SED_CMDS+= -e '/^set [+-]v/d'
+SED_CMDS.opt-debug-jobs+= -e 's,Command: ksh -v,Command: <shell>,'
+SED_CMDS.opt-debug-jobs+= -e 's,Command: <shell> -v,Command: <shell>,'
.endif
.rawout.out:
@${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \
- < ${.IMPSRC} > ${.TARGET}.tmp1
- @${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2
- @rm ${.TARGET}.tmp1
- @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2
- @mv ${.TARGET}.tmp2 ${.TARGET}
+ < ${.IMPSRC} > ${.TARGET}.tmp
+ @${POSTPROC.${.PREFIX:T}:D \
+ ${POSTPROC.${.PREFIX:T}} < ${.TARGET}.tmp > ${.TARGET}.post \
+ && mv ${.TARGET}.post ${.TARGET}.tmp}
+ @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp
+ @mv ${.TARGET}.tmp ${.TARGET}
.if empty(DIFF_FLAGS)
DIFF_ECHO= echo
@@ -802,6 +895,11 @@ test: ${OUTFILES} .PHONY
echo "Failed tests: $${failed}" ; false ; \
else \
echo "All tests passed" ; \
+ lua=${LUA:Ulua} ; \
+ have_lua=$$("$$lua" -e 'print "yes"' 2>&1) ; \
+ if [ "$$have_lua" = "yes" -a -s ${.CURDIR}/check-expect.lua ]; then \
+ (cd ${.CURDIR} && "$$lua" ./check-expect.lua *.mk); \
+ fi; \
fi
accept: