Module Name: src
Committed By: rillig
Date: Sun Aug 16 18:40:13 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: Makefile
Log Message:
make(1): run tests in an almost empty, controlled environment
Several of the tests use simple variable names that might be influenced
by environment variables of the same name. Especially the tests for the
?= variable assignment operator need an empty environment to start with,
to produce reliable results.
The PATH must be in the base environment since several tests depend on
the usual tools like echo(1), sleep(1), grep(1). Setting the PATH to a
fixed value would have made it impossible to run the tests in a custom
environment that don't have a /bin directory. It's the user's
responsibility to provide a sane PATH.
To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/make/unit-tests/Makefile
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.97 src/usr.bin/make/unit-tests/Makefile:1.98
--- src/usr.bin/make/unit-tests/Makefile:1.97 Sun Aug 16 18:17:17 2020
+++ src/usr.bin/make/unit-tests/Makefile Sun Aug 16 18:40:13 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.97 2020/08/16 18:17:17 rillig Exp $
+# $NetBSD: Makefile,v 1.98 2020/08/16 18:40:13 rillig Exp $
#
# Unit tests for make(1)
#
@@ -297,14 +297,9 @@ TESTS+= varparse-dynamic
TESTS+= varquote
TESTS+= varshell
-# Override environment variables for some of the tests.
-ENV.counter= -i
+# Additional environment variables for some of the tests.
+# The base environment is -i PATH="$PATH".
ENV.envfirst= FROM_ENV=value-from-env
-ENV.export= -i PATH=${PATH:Q}
-ENV.export-variants= -i PATH=${PATH:Q}
-ENV.lint= -i
-ENV.make-exported= -i PATH=${PATH:Q}
-ENV.recursive= -i
ENV.varmisc= FROM_ENV=env
ENV.varmisc+= FROM_ENV_BEFORE=env
ENV.varmisc+= FROM_ENV_AFTER=env
@@ -368,9 +363,11 @@ LANG= C
@${_MKMSG_TEST:Uecho '# test '} ${.PREFIX}
@set -eu; \
cd ${.OBJDIR}; \
- env ${ENV.${.TARGET:R}} ${TEST_MAKE} -C ${.CURDIR} \
- -r ${FLAGS.${.TARGET:R}:U-k} -f ${.IMPSRC} \
- > ${.TARGET}.tmp 2>&1 \
+ env -i PATH="$$PATH" ${ENV.${.TARGET:R}} \
+ ${TEST_MAKE} \
+ -r -C ${.CURDIR} -f ${.IMPSRC} \
+ ${FLAGS.${.TARGET:R}:U-k} \
+ > ${.TARGET}.tmp 2>&1 \
&& status=$$? || status=$$?; \
echo $$status > ${.TARGET:R}.status
@mv ${.TARGET}.tmp ${.TARGET}