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 demonstrating the ...



details:   https://anonhg.NetBSD.org/src/rev/1286bdad69df
branches:  trunk
changeset: 956867:1286bdad69df
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 08 20:29:13 2020 +0000

description:
make(1): add test demonstrating the :D modifier with := assignments

diffstat:

 usr.bin/make/unit-tests/varmod-defined.exp |  22 ++++++++++++++++++++++
 usr.bin/make/unit-tests/varmod-defined.mk  |  16 +++++++++++++++-
 2 files changed, 37 insertions(+), 1 deletions(-)

diffs (56 lines):

diff -r 0bdb676393fc -r 1286bdad69df usr.bin/make/unit-tests/varmod-defined.exp
--- a/usr.bin/make/unit-tests/varmod-defined.exp        Sun Nov 08 19:53:11 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-defined.exp        Sun Nov 08 20:29:13 2020 +0000
@@ -1,1 +1,23 @@
+Global:8_DOLLARS = $$$$$$$$
+Global:VAR = 
+Var_Parse: ${8_DOLLARS} with VARE_WANTRES|VARE_KEEP_DOLLAR
+Global:VAR = $$$$$$$$
+Var_Parse: ${VAR:D${8_DOLLARS}} with VARE_WANTRES|VARE_KEEP_DOLLAR
+Applying ${VAR:D...} to "$$$$$$$$" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, none)
+Var_Parse: ${8_DOLLARS}} with VARE_WANTRES|VARE_KEEP_DOLLAR
+Result of ${VAR:D${8_DOLLARS}} is "$$$$$$$$" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, none)
+Global:VAR = $$$$$$$$
+Var_Parse: ${VAR:@var@${8_DOLLARS}@} with VARE_WANTRES|VARE_KEEP_DOLLAR
+Applying ${VAR:@...} to "$$$$$$$$" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, none)
+Modifier part: "var"
+Modifier part: "${8_DOLLARS}"
+ModifyWords: split "$$$$$$$$" into 1 words
+Global:var = $$$$$$$$
+Var_Parse: ${8_DOLLARS} with VARE_WANTRES
+ModifyWord_Loop: in "$$$$$$$$", replace "var" with "${8_DOLLARS}" to "$$$$"
+Global:delete var
+Result of ${VAR:@var@${8_DOLLARS}@} is "$$$$" (VARE_WANTRES|VARE_KEEP_DOLLAR, none, none)
+Global:VAR = $$$$
+Global:.MAKEFLAGS =  -r -k -d v -d
+Global:.MAKEFLAGS =  -r -k -d v -d 0
 exit status 0
diff -r 0bdb676393fc -r 1286bdad69df usr.bin/make/unit-tests/varmod-defined.mk
--- a/usr.bin/make/unit-tests/varmod-defined.mk Sun Nov 08 19:53:11 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-defined.mk Sun Nov 08 20:29:13 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-defined.mk,v 1.7 2020/10/24 08:46:08 rillig Exp $
+# $NetBSD: varmod-defined.mk,v 1.8 2020/11/08 20:29:13 rillig Exp $
 #
 # Tests for the :D variable modifier, which returns the given string
 # if the variable is defined.  It is closely related to the :U modifier.
@@ -85,5 +85,19 @@
 # TODO: Add more tests for parsing the plain text part, to cover each branch
 # of ApplyModifier_Defined.
 
+# The :D and :U modifiers behave differently from the :@var@ modifier in
+# that they preserve dollars in a ':=' assignment.  This is because
+# ApplyModifier_Defined passes the eflags unmodified to Var_Parse, unlike
+# ApplyModifier_Loop, which uses ParseModifierPart, which in turn removes
+# VARE_KEEP_DOLLAR from eflags.
+#
+# XXX: This inconsistency is documented nowhere.
+.MAKEFLAGS: -dv
+8_DOLLARS=     $$$$$$$$
+VAR:=          ${8_DOLLARS}
+VAR:=          ${VAR:D${8_DOLLARS}}
+VAR:=          ${VAR:@var@${8_DOLLARS}@}
+.MAKEFLAGS: -d0
+
 all:
        @:;



Home | Main Index | Thread Index | Old Index