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): prepare test for .export to...



details:   https://anonhg.NetBSD.org/src/rev/ca909e518875
branches:  trunk
changeset: 1012332:ca909e518875
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jul 27 19:45:56 2020 +0000

description:
make(1): prepare test for .export to show all exported variables

Currently the unit tests don't cover exporting of local variables like
.TARGET or @.  To see the effects, all exported variables must be listed
by the tests.

diffstat:

 usr.bin/make/unit-tests/Makefile        |  5 +++--
 usr.bin/make/unit-tests/export-all.mk   |  3 ++-
 usr.bin/make/unit-tests/export.exp      |  2 ++
 usr.bin/make/unit-tests/export.mk       |  7 ++++---
 usr.bin/make/unit-tests/unexport-env.mk |  3 ++-
 usr.bin/make/unit-tests/unexport.mk     |  3 ++-
 6 files changed, 15 insertions(+), 8 deletions(-)

diffs (95 lines):

diff -r 5322b80fef62 -r ca909e518875 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Mon Jul 27 19:23:12 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Mon Jul 27 19:45:56 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.68 2020/07/27 19:23:12 rillig Exp $
+# $NetBSD: Makefile,v 1.69 2020/07/27 19:45:56 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -79,6 +79,7 @@
 
 # Override environment variables for some of the tests.
 ENV.envfirst=          FROM_ENV=value-from-env
+ENV.export=            -i PATH=${PATH:Q}
 ENV.varmisc=           FROM_ENV=env
 ENV.varmisc+=          FROM_ENV_BEFORE=env
 ENV.varmisc+=          FROM_ENV_AFTER=env
@@ -133,7 +134,7 @@
        @echo testing ${.IMPSRC}
        @set -eu; \
        cd ${.OBJDIR}; \
-       ${ENV.${.TARGET:R}} ${TEST_MAKE} \
+       env ${ENV.${.TARGET:R}} ${TEST_MAKE} \
          ${FLAGS.${.TARGET:R}:U-k} -f ${.IMPSRC} \
          > ${.TARGET}.tmp 2>&1 \
        && status=$$? || status=$$?; \
diff -r 5322b80fef62 -r ca909e518875 usr.bin/make/unit-tests/export-all.mk
--- a/usr.bin/make/unit-tests/export-all.mk     Mon Jul 27 19:23:12 2020 +0000
+++ b/usr.bin/make/unit-tests/export-all.mk     Mon Jul 27 19:45:56 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: export-all.mk,v 1.2 2015/04/10 20:41:59 sjg Exp $
+# $Id: export-all.mk,v 1.3 2020/07/27 19:45:56 rillig Exp $
 
 UT_OK=good
 UT_F=fine
@@ -17,6 +17,7 @@
 
 .export
 
+FILTER_CMD=    grep ^UT_
 .include "export.mk"
 
 UT_TEST=export-all
diff -r 5322b80fef62 -r ca909e518875 usr.bin/make/unit-tests/export.exp
--- a/usr.bin/make/unit-tests/export.exp        Mon Jul 27 19:23:12 2020 +0000
+++ b/usr.bin/make/unit-tests/export.exp        Mon Jul 27 19:45:56 2020 +0000
@@ -1,3 +1,5 @@
+.MAKE.LEVEL.ENV=MAKELEVEL
+MAKELEVEL=1
 UT_DOLLAR=This is $UT_FU
 UT_FOO=foobar is fubar
 UT_FU=fubar
diff -r 5322b80fef62 -r ca909e518875 usr.bin/make/unit-tests/export.mk
--- a/usr.bin/make/unit-tests/export.mk Mon Jul 27 19:23:12 2020 +0000
+++ b/usr.bin/make/unit-tests/export.mk Mon Jul 27 19:45:56 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: export.mk,v 1.1 2014/08/21 13:44:51 apb Exp $
+# $Id: export.mk,v 1.2 2020/07/27 19:45:56 rillig Exp $
 
 UT_TEST=export
 UT_FOO=foo${BAR}
@@ -17,6 +17,7 @@
 
 .MAKE.EXPORTED+= UT_ZOO UT_TEST
 
+FILTER_CMD?=   grep -v -E '^(MAKEFLAGS|PATH|PWD)='
+
 all:
-       @env | grep '^UT_' | sort
-
+       @env | ${FILTER_CMD} | sort
diff -r 5322b80fef62 -r ca909e518875 usr.bin/make/unit-tests/unexport-env.mk
--- a/usr.bin/make/unit-tests/unexport-env.mk   Mon Jul 27 19:23:12 2020 +0000
+++ b/usr.bin/make/unit-tests/unexport-env.mk   Mon Jul 27 19:45:56 2020 +0000
@@ -1,6 +1,7 @@
-# $Id: unexport-env.mk,v 1.1 2014/08/21 13:44:52 apb Exp $
+# $Id: unexport-env.mk,v 1.2 2020/07/27 19:45:56 rillig Exp $
 
 # pick up a bunch of exported vars
+FILTER_CMD=    grep ^UT_
 .include "export.mk"
 
 # an example of setting up a minimal environment.
diff -r 5322b80fef62 -r ca909e518875 usr.bin/make/unit-tests/unexport.mk
--- a/usr.bin/make/unit-tests/unexport.mk       Mon Jul 27 19:23:12 2020 +0000
+++ b/usr.bin/make/unit-tests/unexport.mk       Mon Jul 27 19:45:56 2020 +0000
@@ -1,6 +1,7 @@
-# $Id: unexport.mk,v 1.1 2014/08/21 13:44:52 apb Exp $
+# $Id: unexport.mk,v 1.2 2020/07/27 19:45:56 rillig Exp $
 
 # pick up a bunch of exported vars
+FILTER_CMD=    grep ^UT_
 .include "export.mk"
 
 .unexport UT_ZOO UT_FOO



Home | Main Index | Thread Index | Old Index