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): run tests in an almost empt...
details: https://anonhg.NetBSD.org/src/rev/f20d4f6b3fc1
branches: trunk
changeset: 1012954:f20d4f6b3fc1
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Aug 16 18:40:13 2020 +0000
description:
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.
diffstat:
usr.bin/make/unit-tests/Makefile | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
diffs (41 lines):
diff -r 7b5a0878b144 -r f20d4f6b3fc1 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Sun Aug 16 18:17:17 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile Sun Aug 16 18:40:13 2020 +0000
@@ -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+= 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 @@
@${_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}
Home |
Main Index |
Thread Index |
Old Index