summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2022-03-25 23:03:47 +0000
committerrillig <rillig@NetBSD.org>2022-03-25 23:03:47 +0000
commitde36002542008edc8728bb384e595cb730bbd66e (patch)
tree9a1cd6b27b64b561627c1bcd384f0edc36ff7be1 /usr.bin/make
parent05a38480484b39e2521db984e383705e4075de07 (diff)
tests/make: test .undef for exported global variables
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/unit-tests/directive-undef.mk34
1 files changed, 30 insertions, 4 deletions
diff --git a/usr.bin/make/unit-tests/directive-undef.mk b/usr.bin/make/unit-tests/directive-undef.mk
index 41ea6b5bf8f..ddf446e86b9 100644
--- a/usr.bin/make/unit-tests/directive-undef.mk
+++ b/usr.bin/make/unit-tests/directive-undef.mk
@@ -1,4 +1,4 @@
-# $NetBSD: directive-undef.mk,v 1.10 2021/02/16 18:02:19 rillig Exp $
+# $NetBSD: directive-undef.mk,v 1.11 2022/03/25 23:03:47 rillig Exp $
#
# Tests for the .undef directive.
#
@@ -43,11 +43,11 @@
3= 3
${:U1 2 3}= one two three
VARNAMES= 1 2 3
-.undef ${VARNAMES} # undefines the variable "1 2 3"
-.if !defined(${:U1 2 3})
+.undef ${VARNAMES} # undefines the variables "1", "2" and "3"
+.if ${${:U1 2 3}} != "one two three" # still there
. error
.endif
-.if ${1:U_}${2:U_}${3:U_} != "___" # these are still defined
+.if ${1:U_}${2:U_}${3:U_} != "___" # these have been undefined
. error
.endif
@@ -104,4 +104,30 @@ UT_EXPORTED= exported-value
.endif
+# When an exported variable is undefined, the variable is removed both from
+# the global scope as well as from the environment.
+DIRECT= direct
+INDIRECT= in-${DIRECT}
+.export DIRECT INDIRECT
+.if ${DIRECT} != "direct"
+. error
+.endif
+.if ${INDIRECT} != "in-direct"
+. error
+.endif
+
+# Deletes the variables from the global scope and also from the environment.
+# This applies to both variables, even though 'INDIRECT' is not actually
+# exported yet since it refers to another variable.
+.undef DIRECT # Separate '.undef' directives,
+.undef INDIRECT # for backwards compatibility.
+
+.if ${DIRECT:Uundefined} != "undefined"
+. error
+.endif
+.if ${INDIRECT:Uundefined} != "undefined"
+. error
+.endif
+
+
all: