Module Name:    src
Committed By:   rillig
Date:           Tue Aug 25 21:07:39 UTC 2020

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

Log Message:
make(1): add test for ::!= modifier with shell error


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-assign.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-assign.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/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.3 src/usr.bin/make/unit-tests/varmod-assign.exp:1.4
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.3	Tue Aug 25 20:49:40 2020
+++ src/usr.bin/make/unit-tests/varmod-assign.exp	Tue Aug 25 21:07:39 2020
@@ -20,4 +20,7 @@ make: Unknown modifier ':'
 sysv:y
 make: Unfinished modifier for ASSIGN ('}' missing)
 
+ok=word
+make: "previous" returned non-zero status
+err=previous
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.4 src/usr.bin/make/unit-tests/varmod-assign.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.4	Tue Aug 25 20:49:40 2020
+++ src/usr.bin/make/unit-tests/varmod-assign.mk	Tue Aug 25 21:07:39 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign.mk,v 1.4 2020/08/25 20:49:40 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.5 2020/08/25 21:07:39 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
@@ -7,6 +7,7 @@ all:	mod-assign
 all:	mod-assign-nested
 all:	mod-assign-empty
 all:	mod-assign-parse
+all:	mod-assign-shell-error
 
 mod-assign:
 	# The ::?= modifier applies the ?= assignment operator 3 times.
@@ -69,3 +70,12 @@ mod-assign-parse:
 	@echo ${SYSV::=sysv\:x}${SYSV::x=:y}
 
 	@echo ${ASSIGN::=value	# missing closing brace
+
+mod-assign-shell-error:
+	# If the command succeeds, the variable is assigned.
+	@${SH_OK::!= echo word; true} echo ok=${SH_OK}
+
+	# If the command fails, the variable keeps its previous value.
+	# FIXME: the error message says: "previous" returned non-zero status
+	@${SH_ERR::=previous}
+	@${SH_ERR::!= echo word; false} echo err=${SH_ERR}

Reply via email to