Mon Jul 27 19:45:56 2020 UTC ()
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.


(rillig)
diff -r1.68 -r1.69 src/usr.bin/make/unit-tests/Makefile
diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/export-all.mk
diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/export.exp
diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/export.mk
diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/unexport-env.mk
diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/unexport.mk

cvs diff -r1.68 -r1.69 src/usr.bin/make/unit-tests/Makefile (expand / switch to context diff)
--- src/usr.bin/make/unit-tests/Makefile 2020/07/27 19:23:12 1.68
+++ src/usr.bin/make/unit-tests/Makefile 2020/07/27 19:45:56 1.69
@@ -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=$$?; \

cvs diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/export-all.mk (expand / switch to context diff)
--- src/usr.bin/make/unit-tests/export-all.mk 2015/04/10 20:41:59 1.2
+++ src/usr.bin/make/unit-tests/export-all.mk 2020/07/27 19:45:56 1.3
@@ -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

cvs diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/export.exp (expand / switch to context diff)
--- src/usr.bin/make/unit-tests/export.exp 2014/08/21 13:44:51 1.1
+++ src/usr.bin/make/unit-tests/export.exp 2020/07/27 19:45:56 1.2
@@ -1,3 +1,5 @@
+.MAKE.LEVEL.ENV=MAKELEVEL
+MAKELEVEL=1
 UT_DOLLAR=This is $UT_FU
 UT_FOO=foobar is fubar
 UT_FU=fubar

cvs diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/export.mk (expand / switch to context diff)
--- src/usr.bin/make/unit-tests/export.mk 2014/08/21 13:44:51 1.1
+++ src/usr.bin/make/unit-tests/export.mk 2020/07/27 19:45:56 1.2
@@ -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
 
-all:
-	@env | grep '^UT_' | sort
+FILTER_CMD?=	grep -v -E '^(MAKEFLAGS|PATH|PWD)='
 
+all:
+	@env | ${FILTER_CMD} | sort

cvs diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/unexport-env.mk (expand / switch to context diff)
--- src/usr.bin/make/unit-tests/unexport-env.mk 2014/08/21 13:44:52 1.1
+++ src/usr.bin/make/unit-tests/unexport-env.mk 2020/07/27 19:45:56 1.2
@@ -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.

cvs diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/unexport.mk (expand / switch to context diff)
--- src/usr.bin/make/unit-tests/unexport.mk 2014/08/21 13:44:52 1.1
+++ src/usr.bin/make/unit-tests/unexport.mk 2020/07/27 19:45:56 1.2
@@ -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