Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add test for ::!= modifier ...



details:   https://anonhg.NetBSD.org/src/rev/63fd6afbe11b
branches:  trunk
changeset: 943078:63fd6afbe11b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Aug 25 21:07:39 2020 +0000

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

diffstat:

 usr.bin/make/unit-tests/varmod-assign.exp |   3 +++
 usr.bin/make/unit-tests/varmod-assign.mk  |  12 +++++++++++-
 2 files changed, 14 insertions(+), 1 deletions(-)

diffs (41 lines):

diff -r c823d1056318 -r 63fd6afbe11b usr.bin/make/unit-tests/varmod-assign.exp
--- a/usr.bin/make/unit-tests/varmod-assign.exp Tue Aug 25 20:49:40 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-assign.exp Tue Aug 25 21:07:39 2020 +0000
@@ -20,4 +20,7 @@
 sysv:y
 make: Unfinished modifier for ASSIGN ('}' missing)
 
+ok=word
+make: "previous" returned non-zero status
+err=previous
 exit status 0
diff -r c823d1056318 -r 63fd6afbe11b usr.bin/make/unit-tests/varmod-assign.mk
--- a/usr.bin/make/unit-tests/varmod-assign.mk  Tue Aug 25 20:49:40 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-assign.mk  Tue Aug 25 21:07:39 2020 +0000
@@ -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-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 @@
        @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}



Home | Main Index | Thread Index | Old Index