Module Name:    src
Committed By:   rillig
Date:           Fri Aug  7 19:24:27 UTC 2020

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/usr.bin/make/unit-tests: Makefile
Added Files:
        src/usr.bin/make/unit-tests: export-variants.exp export-variants.mk

Log Message:
make(1): add test for exporting variables


To generate a diff of this commit:
cvs rdiff -u -r1.885 -r1.886 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/export-variants.exp \
    src/usr.bin/make/unit-tests/export-variants.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.885 src/distrib/sets/lists/tests/mi:1.886
--- src/distrib/sets/lists/tests/mi:1.885	Thu Aug  6 05:36:32 2020
+++ src/distrib/sets/lists/tests/mi	Fri Aug  7 19:24:27 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.885 2020/08/06 05:36:32 rillig Exp $
+# $NetBSD: mi,v 1.886 2020/08/07 19:24:27 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4558,6 +4558,8 @@
 ./usr/tests/usr.bin/make/unit-tests/export-all.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/export-env.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/export-env.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/export-variants.exp	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/export-variants.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/export.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/export.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/forloop.exp	tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.88 src/usr.bin/make/unit-tests/Makefile:1.89
--- src/usr.bin/make/unit-tests/Makefile:1.88	Fri Aug  7 14:40:59 2020
+++ src/usr.bin/make/unit-tests/Makefile	Fri Aug  7 19:24:27 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.88 2020/08/07 14:40:59 rillig Exp $
+# $NetBSD: Makefile,v 1.89 2020/08/07 19:24:27 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -52,6 +52,7 @@ TESTS+=		# escape	# broken by reverting 
 TESTS+=		export
 TESTS+=		export-all
 TESTS+=		export-env
+TESTS+=		export-variants
 TESTS+=		forloop
 TESTS+=		forsubst
 TESTS+=		hash
@@ -90,6 +91,7 @@ TESTS+=		varshell
 ENV.counter=		-i
 ENV.envfirst=		FROM_ENV=value-from-env
 ENV.export=		-i PATH=${PATH:Q}
+ENV.export-variants=	-i PATH=${PATH:Q}
 ENV.lint=		-i
 ENV.recursive=		-i
 ENV.varmisc=		FROM_ENV=env
@@ -117,6 +119,10 @@ SED_CMDS.varshell+=	-e '/command/s,No su
 POSTPROC.counter=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
 POSTPROC.vardebug=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
 
+export-all.rawout: export.mk
+unexport.rawout: export.mk
+unexport-env.rawout: export.mk
+
 # End of the configuration section.
 
 .MAIN: all

Added files:

Index: src/usr.bin/make/unit-tests/export-variants.exp
diff -u /dev/null src/usr.bin/make/unit-tests/export-variants.exp:1.1
--- /dev/null	Fri Aug  7 19:24:27 2020
+++ src/usr.bin/make/unit-tests/export-variants.exp	Fri Aug  7 19:24:27 2020
@@ -0,0 +1 @@
+exit status 0
Index: src/usr.bin/make/unit-tests/export-variants.mk
diff -u /dev/null src/usr.bin/make/unit-tests/export-variants.mk:1.1
--- /dev/null	Fri Aug  7 19:24:27 2020
+++ src/usr.bin/make/unit-tests/export-variants.mk	Fri Aug  7 19:24:27 2020
@@ -0,0 +1,40 @@
+# $NetBSD: export-variants.mk,v 1.1 2020/08/07 19:24:27 rillig Exp $
+#
+# Test whether exported variables apply to each variant of running
+# external commands:
+#
+# The != assignments.
+# The :!cmd! modifier.
+# The :sh modifier.
+
+SHVAR!=	env | grep ^UT_ || true
+.if ${SHVAR} != ""
+.warning At this point, no variable should be exported.
+.endif
+
+.if ${:!env | grep ^UT_ || true!} != ""
+.warning At this point, no variable should be exported.
+.endif
+
+.if ${env | grep ^UT_ || true:L:sh} != ""
+.warning At this point, no variable should be exported.
+.endif
+
+UT_VAR=		value
+.export UT_VAR
+
+SHVAR!=	env | grep ^UT_ || true
+.if ${SHVAR} != "UT_VAR=value"
+.warning At this point, no variable should be exported.
+.endif
+
+.if ${:!env | grep ^UT_ || true!} != "UT_VAR=value"
+.warning At this point, some variables should be exported.
+.endif
+
+.if ${env | grep ^UT_ || true:L:sh} != "UT_VAR=value"
+.warning At this point, some variables should be exported.
+.endif
+
+all:
+	@:;

Reply via email to