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): explain existing tests for ...



details:   https://anonhg.NetBSD.org/src/rev/0eb43f7fbc96
branches:  trunk
changeset: 956016:0eb43f7fbc96
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 18 21:36:22 2020 +0000

description:
make(1): explain existing tests for the ::= assignment modifiers

diffstat:

 usr.bin/make/unit-tests/varmod-assign.exp |   2 +-
 usr.bin/make/unit-tests/varmod-assign.mk  |  24 ++++++++++++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)

diffs (52 lines):

diff -r 50baca021ff0 -r 0eb43f7fbc96 usr.bin/make/unit-tests/varmod-assign.exp
--- a/usr.bin/make/unit-tests/varmod-assign.exp Sun Oct 18 21:12:13 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-assign.exp Sun Oct 18 21:36:22 2020 +0000
@@ -11,7 +11,7 @@
 mod-assign-nested: then3t3
 mod-assign-nested: else4e4
 make: Bad modifier `:' for 
-value}
+mod-assign-empty: value}
 make: Bad modifier `:' for 
 mod-assign-empty: overwritten}
 mod-assign-empty: VAR=overwritten
diff -r 50baca021ff0 -r 0eb43f7fbc96 usr.bin/make/unit-tests/varmod-assign.mk
--- a/usr.bin/make/unit-tests/varmod-assign.mk  Sun Oct 18 21:12:13 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-assign.mk  Sun Oct 18 21:36:22 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign.mk,v 1.6 2020/08/25 21:16:53 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.7 2020/10/18 21:36:22 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
@@ -51,13 +51,25 @@
 SINK4:=        ${0:?${THEN4::=then4${IT4::=t4}}:${ELSE4::=else4${IE4::=e4}}}${THEN4}${ELSE4}${IT4}${IE4}
 
 mod-assign-empty:
-       # Assigning to the empty variable would obviously not work since that variable
-       # is write-protected.  Therefore it is rejected early as a "bad modifier".
-       @echo ${::=value}
+       # Assigning to the empty variable would obviously not work since that
+       # variable is write-protected.  Therefore it is rejected early with a
+       # "Bad modifier" message.
+       #
+       # XXX: The error message is hard to read since the variable name is
+       # empty.  This leads to a trailing space in the error message.
+       @echo $@: ${::=value}
+
+       # In this variant, it is not as obvious that the name of the
+       # expression is empty.  Assigning to it is rejected as well, with the
+       # same "Bad modifier" message.
+       #
+       # XXX: The error message is hard to read since the variable name is
+       # empty.  This leads to a trailing space in the error message.
        @echo $@: ${:Uvalue::=overwritten}
 
-       # The :L modifier sets the variable's value to its name.
-       # Since the name is still "VAR", assigning to that variable works.
+       # The :L modifier sets the value of the expression to its variable
+       # name.  The name of the expression is "VAR", therefore assigning to
+       # that variable works.
        @echo $@: ${VAR:L::=overwritten} VAR=${VAR}
 
 mod-assign-parse:



Home | Main Index | Thread Index | Old Index