xref: /freebsd/contrib/bmake/unit-tests/directive-unexport.mk (revision a8c56be47166295d37600ff81fc1857db87b3a9b)
1# $NetBSD: directive-unexport.mk,v 1.9 2025/06/30 21:44:39 rillig Exp $
2#
3# Tests for the .unexport directive.
4#
5# Before 2020-12-13, misspelled directives like ".unexporting" or
6# ".unexport-en" had not been detected properly.
7#
8# See also:
9#	directive-misspellings.mk
10
11# First, export 3 variables.
12UT_A=	a
13UT_B=	b
14UT_C=	c
15.export UT_A UT_B UT_C
16
17# Show the exported variables and their values.
18# expect+1: UT_A=a UT_B=b UT_C=c
19.info ${:!env|sort|grep '^UT_'!}
20# expect+1: UT_A UT_B UT_C
21.info ${.MAKE.EXPORTED}
22
23# XXX: Now try to unexport all of them.  The variables are still exported
24# but not mentioned in .MAKE.EXPORTED anymore.
25# See the ":N" in Var_UnExport for the implementation.
26*=	asterisk
27.unexport *
28
29# expect+1: UT_A=a UT_B=b UT_C=c
30.info ${:!env|sort|grep '^UT_'!}
31# expect+1:
32.info ${.MAKE.EXPORTED}
33
34.unexport			# oops: missing argument
35
36all:
37	@:;
38