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 make(1): add test for exporting vari...



details:   https://anonhg.NetBSD.org/src/rev/addd23b4c718
branches:  trunk
changeset: 974653:addd23b4c718
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 07 19:24:27 2020 +0000

description:
make(1): add test for exporting variables

diffstat:

 distrib/sets/lists/tests/mi                 |   4 ++-
 usr.bin/make/unit-tests/Makefile            |   8 +++++-
 usr.bin/make/unit-tests/export-variants.exp |   1 +
 usr.bin/make/unit-tests/export-variants.mk  |  40 +++++++++++++++++++++++++++++
 4 files changed, 51 insertions(+), 2 deletions(-)

diffs (103 lines):

diff -r 6a8bd15a92fd -r addd23b4c718 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Fri Aug 07 18:46:00 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Fri Aug 07 19:24:27 2020 +0000
@@ -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
diff -r 6a8bd15a92fd -r addd23b4c718 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Fri Aug 07 18:46:00 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Fri Aug 07 19:24:27 2020 +0000
@@ -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+=                export
 TESTS+=                export-all
 TESTS+=                export-env
+TESTS+=                export-variants
 TESTS+=                forloop
 TESTS+=                forsubst
 TESTS+=                hash
@@ -90,6 +91,7 @@
 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 @@
 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
diff -r 6a8bd15a92fd -r addd23b4c718 usr.bin/make/unit-tests/export-variants.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/export-variants.exp       Fri Aug 07 19:24:27 2020 +0000
@@ -0,0 +1,1 @@
+exit status 0
diff -r 6a8bd15a92fd -r addd23b4c718 usr.bin/make/unit-tests/export-variants.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/export-variants.mk        Fri Aug 07 19:24:27 2020 +0000
@@ -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:
+       @:;



Home | Main Index | Thread Index | Old Index