Module Name: src Committed By: rillig Date: Fri Mar 25 23:03:47 UTC 2022
Modified Files: src/usr.bin/make/unit-tests: directive-undef.mk Log Message: tests/make: test .undef for exported global variables To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/directive-undef.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/unit-tests/directive-undef.mk diff -u src/usr.bin/make/unit-tests/directive-undef.mk:1.10 src/usr.bin/make/unit-tests/directive-undef.mk:1.11 --- src/usr.bin/make/unit-tests/directive-undef.mk:1.10 Tue Feb 16 18:02:19 2021 +++ src/usr.bin/make/unit-tests/directive-undef.mk Fri Mar 25 23:03:47 2022 @@ -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: