diff options
Diffstat (limited to 'unit-tests')
| -rw-r--r-- | unit-tests/Makefile | 31 | ||||
| -rw-r--r-- | unit-tests/Makefile.config.in | 7 | ||||
| -rwxr-xr-x | unit-tests/directive-dinclude.mk | 2 | ||||
| -rwxr-xr-x | unit-tests/directive-hyphen-include.mk | 2 | ||||
| -rw-r--r-- | unit-tests/directive-include-guard.mk | 4 | ||||
| -rwxr-xr-x | unit-tests/directive-include.mk | 2 | ||||
| -rwxr-xr-x | unit-tests/directive-sinclude.mk | 2 | ||||
| -rw-r--r-- | unit-tests/opt-debug-file.exp | 2 | ||||
| -rw-r--r-- | unit-tests/opt-debug-file.mk | 6 | ||||
| -rw-r--r-- | unit-tests/varmod-sun-shell1.exp | 14 | ||||
| -rw-r--r-- | unit-tests/varmod-sun-shell1.mk | 25 | ||||
| -rw-r--r-- | unit-tests/varname-circumflex.mk | 4 |
12 files changed, 81 insertions, 20 deletions
diff --git a/unit-tests/Makefile b/unit-tests/Makefile index f6c298679a62..63671a6d9b74 100644 --- a/unit-tests/Makefile +++ b/unit-tests/Makefile @@ -1,6 +1,6 @@ -# $Id: Makefile,v 1.245 2025/08/05 16:18:07 sjg Exp $ +# $Id: Makefile,v 1.251 2025/11/15 17:17:18 sjg Exp $ # -# $NetBSD: Makefile,v 1.372 2025/08/04 22:44:49 sjg Exp $ +# $NetBSD: Makefile,v 1.373 2025/11/12 22:14:08 sjg Exp $ # # Unit tests for make(1) # @@ -403,6 +403,7 @@ TESTS+= varmod-shell TESTS+= varmod-subst TESTS+= varmod-subst-regex TESTS+= varmod-sun-shell +TESTS+= varmod-sun-shell1 TESTS+= varmod-sysv TESTS+= varmod-tail TESTS+= varmod-to-abs @@ -519,6 +520,14 @@ BROKEN_TESTS+= \ .endif +.if ${.MAKE.OS:NMINGW*} == "" +BROKEN_TESTS+= \ + cmdline \ + objdir-writable \ + varname-dot-make-level \ + +.endif + .if ${.MAKE.OS} == "SCO_SV" BROKEN_TESTS+= \ opt-debug-graph[23] \ @@ -594,8 +603,12 @@ SED_CMDS.directive-include-guard= \ -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' +.if ${.MAKE.OS:NCygwin:NMINGW*} == "" +SED_CMDS.export+= \ + -e '/MSYSTEM=/d' \ + -e '/^SYSTEMROOT=/d' \ + -e '/^WINDIR=/d' \ + .endif SED_CMDS.export-all= ${SED_CMDS.export} SED_CMDS.export-env= ${SED_CMDS.export} @@ -847,6 +860,12 @@ _SED_CMDS+= -e 's,${.CURDIR},<curdir>,g' # which we get depending on how MAKEOBJDIR is set. _SED_CMDS+= -e 's,${.OBJDIR},<curdir>,g' -e 's,${.OBJDIR:tA},<curdir>,g' .endif + +# At the end, make sure we cleanup any dregs... +.for d in ${MAKEOBJDIRPREFIX:S,/$,,} /usr/obj +_SED_CMDS_LAST+= -e 's,$d,,' +.endfor + # 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,' @@ -868,7 +887,7 @@ SED_CMDS.opt-debug-jobs+= -e 's,Command: <shell> -v,Command: <shell>,' .endif .rawout.out: - @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \ + @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} ${_SED_CMDS_LAST} \ < ${.IMPSRC} > ${.TARGET}.tmp @${POSTPROC.${.PREFIX:T}:D \ ${POSTPROC.${.PREFIX:T}} < ${.TARGET}.tmp > ${.TARGET}.post \ @@ -895,7 +914,7 @@ test: ${OUTFILES} .PHONY echo "Failed tests: $${failed}" ; false ; \ else \ echo "All tests passed" ; \ - lua=${LUA:Ulua} ; \ + lua=${LUA} ; lua=$${lua:-lua}; \ 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); \ diff --git a/unit-tests/Makefile.config.in b/unit-tests/Makefile.config.in index 30049eaa7c26..4ecd8efe7059 100644 --- a/unit-tests/Makefile.config.in +++ b/unit-tests/Makefile.config.in @@ -1,7 +1,8 @@ -# $Id: Makefile.config.in,v 1.4 2022/09/09 18:44:56 sjg Exp $ +# $Id: Makefile.config.in,v 1.5 2025/10/22 23:20:41 sjg Exp $ -srcdir= @srcdir@ +DIFF_FLAGS?= @diff_u@ EGREP= @egrep@ +LUA?= @lua@ TOOL_DIFF?= @diff@ -DIFF_FLAGS?= @diff_u@ UTC_1= @UTC_1@ +srcdir= @srcdir@ diff --git a/unit-tests/directive-dinclude.mk b/unit-tests/directive-dinclude.mk index da063083235f..c05d1a55f51b 100755 --- a/unit-tests/directive-dinclude.mk +++ b/unit-tests/directive-dinclude.mk @@ -18,7 +18,7 @@ # Errors that are not related to opening the file are still reported. # expect: make: directive-dinclude-error.inc:1: Invalid line "syntax error" _!= echo 'syntax error' > directive-dinclude-error.inc -.dinclude "${.CURDIR}/directive-dinclude-error.inc" +.dinclude "${.OBJDIR}/directive-dinclude-error.inc" _!= rm directive-dinclude-error.inc all: .PHONY diff --git a/unit-tests/directive-hyphen-include.mk b/unit-tests/directive-hyphen-include.mk index de438dfaffac..e3817ef15539 100755 --- a/unit-tests/directive-hyphen-include.mk +++ b/unit-tests/directive-hyphen-include.mk @@ -17,7 +17,7 @@ # Errors that are not related to opening the file are still reported. # expect: make: directive-hyphen-include-error.inc:1: Invalid line "syntax error" _!= echo 'syntax error' > directive-hyphen-include-error.inc -.-include "${.CURDIR}/directive-hyphen-include-error.inc" +.-include "${.OBJDIR}/directive-hyphen-include-error.inc" _!= rm directive-hyphen-include-error.inc all: .PHONY diff --git a/unit-tests/directive-include-guard.mk b/unit-tests/directive-include-guard.mk index 702d0f4ab9dc..5dc7f1aac178 100644 --- a/unit-tests/directive-include-guard.mk +++ b/unit-tests/directive-include-guard.mk @@ -636,9 +636,9 @@ LINES.multiline= \ _:= ${fname:H:N.:@dir@${:!mkdir -p ${dir}!}@} _!= printf '%s\n' ${LINES.$i} > ${fname} .MAKEFLAGS: -dp -.include "${.CURDIR}/${fname}" +.include "${.OBJDIR}/${fname}" .undef ${UNDEF_BETWEEN.$i:U} -.include "${.CURDIR}/${fname}" +.include "${.OBJDIR}/${fname}" .MAKEFLAGS: -d0 _!= rm ${fname} _:= ${fname:H:N.:@dir@${:!rmdir ${dir}!}@} diff --git a/unit-tests/directive-include.mk b/unit-tests/directive-include.mk index ad6936ab2f3c..a694b9ca4e91 100755 --- a/unit-tests/directive-include.mk +++ b/unit-tests/directive-include.mk @@ -82,7 +82,7 @@ include # Buf_InitSize, which assumes that bmake_malloc never returns NULL, just like # all other places in the code. _!= > directive-include-empty -.include "${.CURDIR}/directive-include-empty" +.include "${.OBJDIR}/directive-include-empty" _!= rm directive-include-empty diff --git a/unit-tests/directive-sinclude.mk b/unit-tests/directive-sinclude.mk index 4c856d22be4f..3c2ffbdc9f6c 100755 --- a/unit-tests/directive-sinclude.mk +++ b/unit-tests/directive-sinclude.mk @@ -17,7 +17,7 @@ # Errors that are not related to opening the file are still reported. # expect: make: directive-include-error.inc:1: Invalid line "syntax error" _!= echo 'syntax error' > directive-include-error.inc -.sinclude "${.CURDIR}/directive-include-error.inc" +.sinclude "${.OBJDIR}/directive-include-error.inc" _!= rm directive-include-error.inc all: .PHONY diff --git a/unit-tests/opt-debug-file.exp b/unit-tests/opt-debug-file.exp index 4a497f3011d9..2ea5f084f8d6 100644 --- a/unit-tests/opt-debug-file.exp +++ b/unit-tests/opt-debug-file.exp @@ -1,4 +1,4 @@ -make: opt-debug-file.mk:54: This goes to stderr only, once. +make: opt-debug-file.mk:54: This goes to stdout only, once. make: opt-debug-file.mk:57: This goes to stderr only, once. make: opt-debug-file.mk:60: This goes to stderr, and in addition to the debug log. CondParser_Eval: ${:!cat opt-debug-file.debuglog!:Maddition:[#]} != 1 diff --git a/unit-tests/opt-debug-file.mk b/unit-tests/opt-debug-file.mk index d107f177dae3..73a1dac1f6be 100644 --- a/unit-tests/opt-debug-file.mk +++ b/unit-tests/opt-debug-file.mk @@ -1,4 +1,4 @@ -# $NetBSD: opt-debug-file.mk,v 1.12 2025/07/06 08:48:34 rillig Exp $ +# $NetBSD: opt-debug-file.mk,v 1.13 2025/08/09 23:09:55 rillig Exp $ # # Tests for the -dF command line option, which redirects the debug log # to a file instead of writing it to stderr. @@ -50,8 +50,8 @@ DEBUG_OUTPUT:= ${:!cat opt-debug-file.debuglog!:S,\$,\$\$,g} # See Parse_Error. .MAKEFLAGS: -dFstdout -# expect+1: This goes to stderr only, once. -. info This goes to stderr only, once. +# expect+1: This goes to stdout only, once. +. info This goes to stdout only, once. .MAKEFLAGS: -dFstderr # expect+1: This goes to stderr only, once. . info This goes to stderr only, once. diff --git a/unit-tests/varmod-sun-shell1.exp b/unit-tests/varmod-sun-shell1.exp new file mode 100644 index 000000000000..28fd1fa3d481 --- /dev/null +++ b/unit-tests/varmod-sun-shell1.exp @@ -0,0 +1,14 @@ +Global: _ = # (empty) +Var_Parse: ${THE_ANSWER} (eval-keep-dollar-and-undefined) +Var_Parse: ${ANSWER:sh1} (eval-keep-dollar-and-undefined) +Evaluating modifier ${ANSWER:s...} on value "echo 42; (exit 13)" (eval-keep-dollar-and-undefined, regular) +Capturing the output of command "echo 42; (exit 13)" +Global: ignoring delete '.SHELL' as it is not found +Command: .SHELL = /bin/sh +make: varmod-sun-shell1.mk:17: warning: Command "echo 42; (exit 13)" exited with status 13 +Global: .MAKE.SH1.ANSWER = 42 +Result of ${ANSWER:sh1} is "42" (eval-keep-dollar-and-undefined, regular) +Global: _ = 42 +Global: .MAKEFLAGS = -r -k -d v -d +Global: .MAKEFLAGS = -r -k -d v -d 0 +exit status 0 diff --git a/unit-tests/varmod-sun-shell1.mk b/unit-tests/varmod-sun-shell1.mk new file mode 100644 index 000000000000..a15c93450e76 --- /dev/null +++ b/unit-tests/varmod-sun-shell1.mk @@ -0,0 +1,25 @@ +# $NetBSD: varmod-sun-shell1.mk,v 1.1 2025/11/12 22:14:08 sjg Exp $ +# +# Tests for the :sh1 variable modifier, which runs the shell command +# given by the variable value only on first reference and caches its output. +# +# This modifier has been added on 2025-11-11 +# +# See also: +# ApplyModifier_SunShell1 + +ANSWER= echo 42; (exit 13) +THE_ANSWER= ${ANSWER:sh1} + +# first reference will warn +.MAKEFLAGS: -dv # to see the "Capturing" debug output +# expect+1: warning: Command "echo 42; (exit 13)" exited with status 13 +_:= ${THE_ANSWER} +.MAKEFLAGS: -d0 + +# subsequent references will not, since we do not execute a command +.if ${THE_ANSWER} != "42" +. error +.endif + +all: diff --git a/unit-tests/varname-circumflex.mk b/unit-tests/varname-circumflex.mk index 270f7123781b..4825db5794f5 100644 --- a/unit-tests/varname-circumflex.mk +++ b/unit-tests/varname-circumflex.mk @@ -1,7 +1,9 @@ -# $NetBSD: varname-circumflex.mk,v 1.1 2025/06/27 20:20:56 rillig Exp $ +# $NetBSD: varname-circumflex.mk,v 1.2 2025/08/09 23:13:29 rillig Exp $ # # Tests for the target-local variable "^", which is required by POSIX 2024 # and provided by GNU make. +# +# https://gnats.netbsd.org/59018 # TODO: Support $^. |
