diff options
Diffstat (limited to 'contrib/bmake/unit-tests/var-op-shell.mk')
-rw-r--r-- | contrib/bmake/unit-tests/var-op-shell.mk | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/contrib/bmake/unit-tests/var-op-shell.mk b/contrib/bmake/unit-tests/var-op-shell.mk index bd2a48f17cc4..f9c7c717b8f1 100644 --- a/contrib/bmake/unit-tests/var-op-shell.mk +++ b/contrib/bmake/unit-tests/var-op-shell.mk @@ -1,4 +1,4 @@ -# $NetBSD: var-op-shell.mk,v 1.6 2022/01/10 20:32:29 rillig Exp $ +# $NetBSD: var-op-shell.mk,v 1.11 2025/01/11 21:21:33 rillig Exp $ # # Tests for the != variable assignment operator, which runs its right-hand # side through the shell. @@ -28,13 +28,15 @@ OUTPUT!= true # '::!=', expression modifier ':!...!'), a failed command generates only a # warning, not an "error". These "errors" are ignored in default mode, for # compatibility, but not in lint mode (-dL). -OUTPUT!= echo "failed"; false +# expect+1: warning: Command "echo "failed"; (exit 13)" exited with status 13 +OUTPUT!= echo "failed"; (exit 13) .if ${OUTPUT} != "failed" . error .endif # A command with empty output may fail as well. -OUTPUT!= false +# expect+1: warning: Command "exit 13" exited with status 13 +OUTPUT!= exit 13 .if ${OUTPUT} != "" . error .endif @@ -48,7 +50,7 @@ OUTPUT!= echo "line 1"; echo "line 2" # A failing command in the middle results in the exit status 0, which in the # end means that the whole sequence of commands succeeded. -OUTPUT!= echo "before"; false; echo "after" +OUTPUT!= echo "before"; (exit 13); echo "after" .if ${OUTPUT} != "before after" . error .endif @@ -56,12 +58,14 @@ OUTPUT!= echo "before"; false; echo "after" # This should result in a warning about "exited on a signal". # This used to be kill -14 (SIGALRM), but that stopped working on # Darwin18 after recent update. +# expect+1: warning: "kill $$" exited on a signal OUTPUT!= kill $$$$ .if ${OUTPUT} != "" . error .endif # A nonexistent command produces a non-zero exit status. +# expect+1: warning: Command "/bin/no/such/command" exited with status 127 OUTPUT!= /bin/no/such/command .if ${OUTPUT} != "" . error @@ -87,4 +91,31 @@ OUTPUT!= echo '$$$$$$$$' OUTPUT!= echo '$$$$$$$$' .MAKEFLAGS: -d0 + +# Since main.c 1.607 from 2024-01-05, long shell commands are not run directly +# via '$shell -c $command', they are first written to a temporary file that is +# then fed to the shell via '$shell $tmpfile'. +OUTPUT_SHORT!= echo "$$0" +OUTPUT_LONG!= echo "$$0" || : ${:U:range=1000} +# When running '$shell -c $command', '$0' in the shell evaluates to the name +# of the shell. +.if ${OUTPUT_SHORT:T} != ${.SHELL:T} +. error +.endif +# When running '$shell $tmpfile', '$0' in the shell evaluates to the name of +# the temporary file. +.if !${OUTPUT_LONG:M*/make*} +. error +.endif + + +# An undefined expression results in an empty string. +.MAKEFLAGS: -dv +OUTPUT_OF_UNDEF!= echo x${UNDEF}y +.if ${OUTPUT_OF_UNDEF} != "xy" +. error +.endif +.MAKEFLAGS: -d0 + + all: |