Module Name: src
Committed By: rillig
Date: Tue Dec 28 00:56:17 UTC 2021
Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: varmod-assign-shell.exp
varmod-assign-shell.mk
Log Message:
tests/make: document inconsistencies between '!=' and '::!='
Found while trying to make the error messages from Cmd_Exec more
detailed.
To generate a diff of this commit:
cvs rdiff -u -r1.1180 -r1.1181 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.291 -r1.292 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-assign-shell.exp \
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/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1180 src/distrib/sets/lists/tests/mi:1.1181
--- src/distrib/sets/lists/tests/mi:1.1180 Thu Dec 23 11:05:58 2021
+++ src/distrib/sets/lists/tests/mi Tue Dec 28 00:56:16 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1180 2021/12/23 11:05:58 rillig Exp $
+# $NetBSD: mi,v 1.1181 2021/12/28 00:56:16 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -5967,6 +5967,8 @@
./usr/tests/usr.bin/make/unit-tests/varfind.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmisc.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmisc.mk tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varmod-assign-shell.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varmod-assign-shell.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmod-assign.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmod-assign.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmod-defined.exp tests-usr.bin-tests compattestfile,atf
Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.291 src/usr.bin/make/unit-tests/Makefile:1.292
--- src/usr.bin/make/unit-tests/Makefile:1.291 Thu Dec 23 11:05:59 2021
+++ src/usr.bin/make/unit-tests/Makefile Tue Dec 28 00:56:17 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.291 2021/12/23 11:05:59 rillig Exp $
+# $NetBSD: Makefile,v 1.292 2021/12/28 00:56:17 rillig Exp $
#
# Unit tests for make(1)
#
@@ -342,6 +342,7 @@ TESTS+= varfind
TESTS+= varmisc
TESTS+= varmod
TESTS+= varmod-assign
+TESTS+= varmod-assign-shell
TESTS+= varmod-defined
TESTS+= varmod-edge
TESTS+= varmod-exclam-shell
Added files:
Index: src/usr.bin/make/unit-tests/varmod-assign-shell.exp
diff -u /dev/null src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.1
--- /dev/null Tue Dec 28 00:56:17 2021
+++ src/usr.bin/make/unit-tests/varmod-assign-shell.exp Tue Dec 28 00:56:17 2021
@@ -0,0 +1,5 @@
+make: "varmod-assign-shell.mk" line 25: warning: "echo output; false" returned non-zero status
+make: "echo output; false" returned non-zero status
+DIRECT=output
+ASSIGNED=previous
+exit status 0
Index: src/usr.bin/make/unit-tests/varmod-assign-shell.mk
diff -u /dev/null src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.1
--- /dev/null Tue Dec 28 00:56:17 2021
+++ src/usr.bin/make/unit-tests/varmod-assign-shell.mk Tue Dec 28 00:56:17 2021
@@ -0,0 +1,32 @@
+# $NetBSD: varmod-assign-shell.mk,v 1.1 2021/12/28 00:56:17 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.
+#
+# The variable modifier '::!=' and its close relatives have been around since
+# var.c 1.45 from 2000-06-01.
+#
+# Before 2020.08.25.21.16.53, the variable modifier '::!=' had a bug for
+# unsuccessful commands, it put the previous value of the variable into the
+# error message instead of the command that was executed. That's where the
+# counterintuitive error message 'make: "previous" returned non-zero status'
+# comes from.
+#
+# BUGS
+# Even though the variable modifier '::!=' produces an error message,
+# the exit status of make is still 0.
+#
+# Having an error message instead of a warning like for the variable
+# assignment operator '!=' is another unnecessary inconsistency.
+
+DIRECT= previous
+DIRECT!= echo output; false
+
+ASSIGNED= previous
+_:= ${ASSIGNED::!=echo output; false}
+
+all:
+ @echo DIRECT=${DIRECT:Q}
+ @echo ASSIGNED=${ASSIGNED:Q}