Module Name:    src
Committed By:   rillig
Date:           Sun Aug 20 20:48:33 UTC 2023

Modified Files:
        src/usr.bin/make/unit-tests: directive-export-gmake.exp
            directive-export-gmake.mk directive-export.exp directive-export.mk

Log Message:
tests/make: show a difference between 'export' and '.export'


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
    src/usr.bin/make/unit-tests/directive-export-gmake.exp \
    src/usr.bin/make/unit-tests/directive-export.exp
cvs rdiff -u -r1.6 -r1.7 \
    src/usr.bin/make/unit-tests/directive-export-gmake.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-export.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-export-gmake.exp
diff -u src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.4 src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.5
--- src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.4	Sat Aug 19 11:09:02 2023
+++ src/usr.bin/make/unit-tests/directive-export-gmake.exp	Sun Aug 20 20:48:32 2023
@@ -1,4 +1,5 @@
 make: "directive-export-gmake.mk" line 71: Invalid line 'export VAR=${:U1}', expanded to 'export VAR=1'
+make: "directive-export-gmake.mk" line 85: 16:00:00
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/directive-export.exp
diff -u src/usr.bin/make/unit-tests/directive-export.exp:1.4 src/usr.bin/make/unit-tests/directive-export.exp:1.5
--- src/usr.bin/make/unit-tests/directive-export.exp:1.4	Sun Dec 13 01:07:54 2020
+++ src/usr.bin/make/unit-tests/directive-export.exp	Sun Aug 20 20:48:32 2023
@@ -1 +1,4 @@
+make: "directive-export.mk" line 50: 00:00:00
+make: "directive-export.mk" line 55: 00:00:00
+make: "directive-export.mk" line 58: 16:00:00
 exit status 0

Index: src/usr.bin/make/unit-tests/directive-export-gmake.mk
diff -u src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.6 src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.7
--- src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.6	Sat Aug 19 11:09:02 2023
+++ src/usr.bin/make/unit-tests/directive-export-gmake.mk	Sun Aug 20 20:48:32 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-export-gmake.mk,v 1.6 2023/08/19 11:09:02 rillig Exp $
+# $NetBSD: directive-export-gmake.mk,v 1.7 2023/08/20 20:48:32 rillig Exp $
 #
 # Tests for the export directive (without leading dot), as in GNU make.
 
@@ -70,3 +70,16 @@ export VAR=an ${UNDEF} variable
 # expect+1: Invalid line 'export VAR=${:U1}'
 export VAR=${value}
 .endfor
+
+
+# The 'export' directive expands expressions, but the expressions must not
+# contain a ':', due to the overly strict parser.  The indirect expressions
+# may contain a ':', though.
+#
+# As a side effect, this test demonstrates that the 'export' directive exports
+# the environment variable immediately, other than the '.export' directive,
+# which defers that action if the variable value contains a '$'.
+INDIRECT_TZ=	${:UAmerica/Los_Angeles}
+export TZ=${INDIRECT_TZ}
+# expect+1: 16:00:00
+.info ${%T:L:localtime=86400}

Index: src/usr.bin/make/unit-tests/directive-export.mk
diff -u src/usr.bin/make/unit-tests/directive-export.mk:1.8 src/usr.bin/make/unit-tests/directive-export.mk:1.9
--- src/usr.bin/make/unit-tests/directive-export.mk:1.8	Tue Feb 16 19:01:18 2021
+++ src/usr.bin/make/unit-tests/directive-export.mk	Sun Aug 20 20:48:32 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-export.mk,v 1.8 2021/02/16 19:01:18 rillig Exp $
+# $NetBSD: directive-export.mk,v 1.9 2023/08/20 20:48:32 rillig Exp $
 #
 # Tests for the .export directive.
 #
@@ -41,4 +41,21 @@ EMPTY_SHELL=	${:sh}
 _!=		:;:	# Force the variable to be actually exported.
 
 
+# If the '.export' directive exports a variable whose value contains a '$',
+# the actual export action is deferred until a subprocess is started, assuming
+# that only subprocesses access the environment variables.  The ':localtime'
+# modifier depends on the 'TZ' environment variable, without any subprocess.
+export TZ=${UTC}
+# expect+1: 00:00:00
+.info ${%T:L:localtime=86400}
+INDIRECT_TZ=	${:UAmerica/Los_Angeles}
+TZ=		${INDIRECT_TZ}
+.export TZ
+# expect+1: 00:00:00
+.info ${%T:L:localtime=86400}
+_!=	echo 'force exporting the environment variables'
+# expect+1: 16:00:00
+.info ${%T:L:localtime=86400}
+
+
 all:

Reply via email to