Sun Jul 26 20:30:42 2020 UTC ()
make(1): add test for expanding dynamic variables


(rillig)
diff -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmisc.exp
diff -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmisc.mk

cvs diff -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmisc.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmisc.exp 2020/07/26 11:10:29 1.10
+++ src/usr.bin/make/unit-tests/varmisc.exp 2020/07/26 20:30:42 1.11
@@ -33,14 +33,15 @@ save-dollars: true = $$ @@ -33,14 +33,15 @@ save-dollars: true = $$
33save-dollars: Yes = $$ 33save-dollars: Yes = $$
34save-dollars: No = $ 34save-dollars: No = $
35save-dollars: yes = $$ 35save-dollars: yes = $$
36save-dollars: no = $ 36save-dollars: no = $
37save-dollars: On = $$ 37save-dollars: On = $$
38save-dollars: Off = $ 38save-dollars: Off = $
39save-dollars: ON = $$ 39save-dollars: ON = $$
40save-dollars: OFF = $ 40save-dollars: OFF = $
41save-dollars: on = $$ 41save-dollars: on = $$
42save-dollars: off = $ 42save-dollars: off = $
43export-appended: env 43export-appended: env
44export-appended: env 44export-appended: env
45export-appended: env mk 45export-appended: env mk
 46parse-dynamic: parse-dynamic parse-dynamic before
46exit status 0 47exit status 0

cvs diff -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmisc.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmisc.mk 2020/07/26 11:10:29 1.14
+++ src/usr.bin/make/unit-tests/varmisc.mk 2020/07/26 20:30:42 1.15
@@ -1,21 +1,22 @@ @@ -1,21 +1,22 @@
1# $Id: varmisc.mk,v 1.14 2020/07/26 11:10:29 rillig Exp $ 1# $Id: varmisc.mk,v 1.15 2020/07/26 20:30:42 rillig Exp $
2# 2#
3# Miscellaneous variable tests. 3# Miscellaneous variable tests.
4 4
5all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \ 5all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \
6 strftime cmpv manok 6 strftime cmpv manok
7all: save-dollars 7all: save-dollars
8all: export-appended 8all: export-appended
 9all: parse-dynamic
9 10
10unmatched_var_paren: 11unmatched_var_paren:
11 @echo ${foo::=foo-text} 12 @echo ${foo::=foo-text}
12 13
13True = ${echo true >&2:L:sh}TRUE 14True = ${echo true >&2:L:sh}TRUE
14False= ${echo false >&2:L:sh}FALSE 15False= ${echo false >&2:L:sh}FALSE
15 16
16VSET= is set 17VSET= is set
17.undef UNDEF 18.undef UNDEF
18 19
19U_false: 20U_false:
20 @echo :U skipped when var set 21 @echo :U skipped when var set
21 @echo ${VSET:U${False}} 22 @echo ${VSET:U${False}}
@@ -146,13 +147,30 @@ VAR.${param}= ${param} @@ -146,13 +147,30 @@ VAR.${param}= ${param}
146# The appended value is not exported automatically. 147# The appended value is not exported automatically.
147# When a variable is exported, the exported value is taken at the time of the 148# When a variable is exported, the exported value is taken at the time of the
148# .export directive. Later changes to the variable have no effect. 149# .export directive. Later changes to the variable have no effect.
149.export FROM_ENV_BEFORE 150.export FROM_ENV_BEFORE
150FROM_ENV+= mk 151FROM_ENV+= mk
151FROM_ENV_BEFORE+= mk 152FROM_ENV_BEFORE+= mk
152FROM_ENV_AFTER+= mk 153FROM_ENV_AFTER+= mk
153.export FROM_ENV_AFTER 154.export FROM_ENV_AFTER
154 155
155export-appended: 156export-appended:
156 @echo $@: "$$FROM_ENV" 157 @echo $@: "$$FROM_ENV"
157 @echo $@: "$$FROM_ENV_BEFORE" 158 @echo $@: "$$FROM_ENV_BEFORE"
158 @echo $@: "$$FROM_ENV_AFTER" 159 @echo $@: "$$FROM_ENV_AFTER"
 160
 161# begin parse-dynamic
 162#
 163# Demonstrate that the target-specific variables are not evaluated in
 164# the global context. They are preserved until there is a local context
 165# in which resolving them makes sense.
 166
 167${:U>}= before
 168G_TARGET:= $@
 169G_MEMBER:= $%
 170G_PREFIX:= $*
 171G_ARCHIVE:= $!
 172G_ALLSRC:= $>
 173${:U>}= after
 174
 175parse-dynamic:
 176 @echo $@: ${G_TARGET} ${G_MEMBER} ${G_PREFIX} ${G_ARCHIVE} ${G_ALLSRC}