Module Name: src Committed By: rillig Date: Mon Jul 27 19:45:56 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: Makefile export-all.mk export.exp export.mk unexport-env.mk unexport.mk Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/export-all.mk cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/export.exp \ src/usr.bin/make/unit-tests/export.mk \ src/usr.bin/make/unit-tests/unexport-env.mk \ src/usr.bin/make/unit-tests/unexport.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/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.68 src/usr.bin/make/unit-tests/Makefile:1.69 --- src/usr.bin/make/unit-tests/Makefile:1.68 Mon Jul 27 19:23:12 2020 +++ src/usr.bin/make/unit-tests/Makefile Mon Jul 27 19:45:56 2020 @@ -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 @@ TESTS+= varshell # 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 @@ LANG= C @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=$$?; \ Index: src/usr.bin/make/unit-tests/export-all.mk diff -u src/usr.bin/make/unit-tests/export-all.mk:1.2 src/usr.bin/make/unit-tests/export-all.mk:1.3 --- src/usr.bin/make/unit-tests/export-all.mk:1.2 Fri Apr 10 20:41:59 2015 +++ src/usr.bin/make/unit-tests/export-all.mk Mon Jul 27 19:45:56 2020 @@ -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 @@ UT_OKDIR = ${${here}/../${here:T}:L:${M_ .export +FILTER_CMD= grep ^UT_ .include "export.mk" UT_TEST=export-all Index: src/usr.bin/make/unit-tests/export.exp diff -u src/usr.bin/make/unit-tests/export.exp:1.1 src/usr.bin/make/unit-tests/export.exp:1.2 --- src/usr.bin/make/unit-tests/export.exp:1.1 Thu Aug 21 13:44:51 2014 +++ src/usr.bin/make/unit-tests/export.exp Mon Jul 27 19:45:56 2020 @@ -1,3 +1,5 @@ +.MAKE.LEVEL.ENV=MAKELEVEL +MAKELEVEL=1 UT_DOLLAR=This is $UT_FU UT_FOO=foobar is fubar UT_FU=fubar Index: src/usr.bin/make/unit-tests/export.mk diff -u src/usr.bin/make/unit-tests/export.mk:1.1 src/usr.bin/make/unit-tests/export.mk:1.2 --- src/usr.bin/make/unit-tests/export.mk:1.1 Thu Aug 21 13:44:51 2014 +++ src/usr.bin/make/unit-tests/export.mk Mon Jul 27 19:45:56 2020 @@ -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 @@ BAR=bar is ${UT_FU} .MAKE.EXPORTED+= UT_ZOO UT_TEST -all: - @env | grep '^UT_' | sort +FILTER_CMD?= grep -v -E '^(MAKEFLAGS|PATH|PWD)=' +all: + @env | ${FILTER_CMD} | sort Index: src/usr.bin/make/unit-tests/unexport-env.mk diff -u src/usr.bin/make/unit-tests/unexport-env.mk:1.1 src/usr.bin/make/unit-tests/unexport-env.mk:1.2 --- src/usr.bin/make/unit-tests/unexport-env.mk:1.1 Thu Aug 21 13:44:52 2014 +++ src/usr.bin/make/unit-tests/unexport-env.mk Mon Jul 27 19:45:56 2020 @@ -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. Index: src/usr.bin/make/unit-tests/unexport.mk diff -u src/usr.bin/make/unit-tests/unexport.mk:1.1 src/usr.bin/make/unit-tests/unexport.mk:1.2 --- src/usr.bin/make/unit-tests/unexport.mk:1.1 Thu Aug 21 13:44:52 2014 +++ src/usr.bin/make/unit-tests/unexport.mk Mon Jul 27 19:45:56 2020 @@ -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