Module Name:    src
Committed By:   rillig
Date:           Sun Jan  9 18:22:32 UTC 2022

Modified Files:
        src/usr.bin/make/unit-tests: var-op-shell.exp var-op-shell.mk
            varmod-assign-shell.exp varmod-assign-shell.mk

Log Message:
tests/make: demonstrate inconsistencies in Cmd_Exec callers

The assignment 'VAR != cmd' generates a warning, the others generate an
error message.  That error message is ignored for backwards
compatibility though.

The assignment via the expression ${VAR::!=cmd} only uses the output of
the command if there was no error, the other places use the output
nevertheless.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-op-shell.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/var-op-shell.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-assign-shell.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-assign-shell.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/var-op-shell.exp
diff -u src/usr.bin/make/unit-tests/var-op-shell.exp:1.3 src/usr.bin/make/unit-tests/var-op-shell.exp:1.4
--- src/usr.bin/make/unit-tests/var-op-shell.exp:1.3	Sat Feb  6 04:55:08 2021
+++ src/usr.bin/make/unit-tests/var-op-shell.exp	Sun Jan  9 18:22:31 2022
@@ -1,7 +1,7 @@
-make: "var-op-shell.mk" line 28: warning: "echo "failed"; false" returned non-zero status
-make: "var-op-shell.mk" line 34: warning: "false" returned non-zero status
-make: "var-op-shell.mk" line 56: warning: "kill $$" exited on a signal
+make: "var-op-shell.mk" line 31: warning: "echo "failed"; false" returned non-zero status
+make: "var-op-shell.mk" line 37: warning: "false" returned non-zero status
+make: "var-op-shell.mk" line 59: warning: "kill $$" exited on a signal
 /bin/no/such/command: not found
-make: "var-op-shell.mk" line 62: warning: "/bin/no/such/command" returned non-zero status
+make: "var-op-shell.mk" line 65: warning: "/bin/no/such/command" returned non-zero status
 stderr
 exit status 0

Index: src/usr.bin/make/unit-tests/var-op-shell.mk
diff -u src/usr.bin/make/unit-tests/var-op-shell.mk:1.4 src/usr.bin/make/unit-tests/var-op-shell.mk:1.5
--- src/usr.bin/make/unit-tests/var-op-shell.mk:1.4	Sat Feb  6 04:55:08 2021
+++ src/usr.bin/make/unit-tests/var-op-shell.mk	Sun Jan  9 18:22:31 2022
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-shell.mk,v 1.4 2021/02/06 04:55:08 sjg Exp $
+# $NetBSD: var-op-shell.mk,v 1.5 2022/01/09 18:22:31 rillig Exp $
 #
 # Tests for the != variable assignment operator, which runs its right-hand
 # side through the shell.
@@ -15,7 +15,7 @@ OUTPUT!=	echo "success"'ful'
 # an empty output produced the error message "Couldn't read shell's output
 # for \"%s\"".
 #
-# The error message is still there but reserved for technical errors.
+# The error message is still in Cmd_Exec but reserved for technical errors.
 # It may be possible to trigger the error message by killing the shell after
 # reading part of its output.
 OUTPUT!=	true
@@ -24,7 +24,10 @@ OUTPUT!=	true
 .endif
 
 # The output of a shell command that failed is processed nevertheless.
-# TODO: Make this an error in lint mode.
+# Unlike the other places that run external commands (expression modifier
+# '::!=', 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
 .if ${OUTPUT} != "failed"
 .  error

Index: src/usr.bin/make/unit-tests/varmod-assign-shell.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.1 src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.2
--- src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.1	Tue Dec 28 00:56:17 2021
+++ src/usr.bin/make/unit-tests/varmod-assign-shell.exp	Sun Jan  9 18:22:31 2022
@@ -1,4 +1,4 @@
-make: "varmod-assign-shell.mk" line 25: warning: "echo output; false" returned non-zero status
+make: "varmod-assign-shell.mk" line 27: warning: "echo output; false" returned non-zero status
 make: "echo output; false" returned non-zero status
 DIRECT=output
 ASSIGNED=previous

Index: src/usr.bin/make/unit-tests/varmod-assign-shell.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.2 src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.3
--- src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.2	Tue Dec 28 10:47:00 2021
+++ src/usr.bin/make/unit-tests/varmod-assign-shell.mk	Sun Jan  9 18:22:31 2022
@@ -1,9 +1,11 @@
-# $NetBSD: varmod-assign-shell.mk,v 1.2 2021/12/28 10:47:00 rillig Exp $
+# $NetBSD: varmod-assign-shell.mk,v 1.3 2022/01/09 18:22:31 rillig Exp $
 #
 # Tests for the variable modifier '::!=', which assigns the output of a shell
 # command to the variable, but only if the command exited successfully.  This
-# is different from the variable assignment operator '!=', which also assigns
-# when the shell command fails or crashes.
+# is different from the other places that capture the output of an external
+# command (variable assignment operator '!=', expression modifier ':sh',
+# expression modifier ':!...!'), which also use the output when the shell
+# command fails or crashes.
 #
 # The variable modifier '::!=' and its close relatives have been around since
 # var.c 1.45 from 2000-06-01.

Reply via email to