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 appending and ...
details: https://anonhg.NetBSD.org/src/rev/848a9a21c83a
branches: trunk
changeset: 974210:848a9a21c83a
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 26 11:10:29 2020 +0000
description:
make(1): add test for appending and exporting a variable
diffstat:
usr.bin/make/unit-tests/Makefile | 5 ++++-
usr.bin/make/unit-tests/varmisc.exp | 3 +++
usr.bin/make/unit-tests/varmisc.mk | 19 ++++++++++++++++++-
3 files changed, 25 insertions(+), 2 deletions(-)
diffs (66 lines):
diff -r 7ac5ea70329a -r 848a9a21c83a usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Sun Jul 26 11:05:39 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile Sun Jul 26 11:10:29 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.64 2020/07/25 21:19:29 rillig Exp $
+# $NetBSD: Makefile,v 1.65 2020/07/26 11:10:29 rillig Exp $
#
# Unit tests for make(1)
#
@@ -77,6 +77,9 @@
# Override environment variables for some of the tests.
ENV.envfirst= FROM_ENV=value-from-env
+ENV.varmisc= FROM_ENV=env
+ENV.varmisc+= FROM_ENV_BEFORE=env
+ENV.varmisc+= FROM_ENV_AFTER=env
# Override make flags for some of the tests; default is -k.
FLAGS.doterror= # none
diff -r 7ac5ea70329a -r 848a9a21c83a usr.bin/make/unit-tests/varmisc.exp
--- a/usr.bin/make/unit-tests/varmisc.exp Sun Jul 26 11:05:39 2020 +0000
+++ b/usr.bin/make/unit-tests/varmisc.exp Sun Jul 26 11:10:29 2020 +0000
@@ -40,4 +40,7 @@
save-dollars: OFF = $
save-dollars: on = $$
save-dollars: off = $
+export-appended: env
+export-appended: env
+export-appended: env mk
exit status 0
diff -r 7ac5ea70329a -r 848a9a21c83a usr.bin/make/unit-tests/varmisc.mk
--- a/usr.bin/make/unit-tests/varmisc.mk Sun Jul 26 11:05:39 2020 +0000
+++ b/usr.bin/make/unit-tests/varmisc.mk Sun Jul 26 11:10:29 2020 +0000
@@ -1,10 +1,11 @@
-# $Id: varmisc.mk,v 1.13 2020/07/26 10:59:56 rillig Exp $
+# $Id: varmisc.mk,v 1.14 2020/07/26 11:10:29 rillig Exp $
#
# Miscellaneous variable tests.
all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \
strftime cmpv manok
all: save-dollars
+all: export-appended
unmatched_var_paren:
@echo ${foo::=foo-text}
@@ -139,3 +140,19 @@
.if ${VAR.+} != "+" || ${VAR.!} != "!" || ${VAR.?} != "?"
.error "${VAR.+}" "${VAR.!}" "${VAR.?}"
.endif
+
+# Appending to a variable from the environment creates a copy of that variable
+# in the global context.
+# The appended value is not exported automatically.
+# When a variable is exported, the exported value is taken at the time of the
+# .export directive. Later changes to the variable have no effect.
+.export FROM_ENV_BEFORE
+FROM_ENV+= mk
+FROM_ENV_BEFORE+= mk
+FROM_ENV_AFTER+= mk
+.export FROM_ENV_AFTER
+
+export-appended:
+ @echo $@: "$$FROM_ENV"
+ @echo $@: "$$FROM_ENV_BEFORE"
+ @echo $@: "$$FROM_ENV_AFTER"
Home |
Main Index |
Thread Index |
Old Index