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 tests/make: test .undef for exported...



details:   https://anonhg.NetBSD.org/src/rev/ae150fd51f2f
branches:  trunk
changeset: 364453:ae150fd51f2f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Mar 25 23:03:47 2022 +0000

description:
tests/make: test .undef for exported global variables

diffstat:

 usr.bin/make/unit-tests/directive-undef.mk |  34 ++++++++++++++++++++++++++---
 1 files changed, 30 insertions(+), 4 deletions(-)

diffs (55 lines):

diff -r f6ae6c7d154b -r ae150fd51f2f usr.bin/make/unit-tests/directive-undef.mk
--- a/usr.bin/make/unit-tests/directive-undef.mk        Fri Mar 25 22:38:39 2022 +0000
+++ b/usr.bin/make/unit-tests/directive-undef.mk        Fri Mar 25 23:03:47 2022 +0000
@@ -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 @@
 .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:



Home | Main Index | Thread Index | Old Index