summaryrefslogtreecommitdiff
path: root/tests/test_driver.pl
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2020-04-01 01:58:33 -0400
committerPaul Smith <psmith@gnu.org>2020-04-01 02:02:57 -0400
commitf79bde1a6d6899641370835fb2aafcd8ec224301 (patch)
tree35f9a3e5a3dfc8c8363ca42ec38cbae13c1a276d /tests/test_driver.pl
parent289108cc9bef892a46bba9b11e6989b36107415d (diff)
downloadmake-git-f79bde1a6d6899641370835fb2aafcd8ec224301.tar.gz
tests: Simplify customization of %ENV
Rather than having an %extraENV that is added to the default %ENV and resetting %ENV _before_ each test, allow the test setup to modify %ENV directly as needed then reset %ENV _after_ each test. * tests/test_driver.pl: Remove unused %extraENV. (resetENV): Don't add in %extraENV. (_run_command): Reset after we run the command rather than before. * tests/scripts/features/export: Convert %extraENV to %ENV * tests/scripts/features/jobserver: Ditto * tests/scripts/features/parallelism: Ditto * tests/scripts/features/targetvars: Ditto * tests/scripts/functions/eval: Ditto * tests/scripts/functions/foreach: Ditto * tests/scripts/functions/origin: Ditto * tests/scripts/misc/general4: Ditto * tests/scripts/options/dash-e: Ditto * tests/scripts/targets/POSIX: Ditto * tests/scripts/variables/GNUMAKEFLAGS: Ditto * tests/scripts/variables/SHELL: Ditto
Diffstat (limited to 'tests/test_driver.pl')
-rw-r--r--tests/test_driver.pl19
1 files changed, 4 insertions, 15 deletions
diff --git a/tests/test_driver.pl b/tests/test_driver.pl
index ccd43c5f..ec17be1f 100644
--- a/tests/test_driver.pl
+++ b/tests/test_driver.pl
@@ -83,13 +83,9 @@ if ($^O ne 'VMS') {
# in recipes
$perl_name =~ tr,\\,/,;
-# %makeENV is the cleaned-out environment.
+# %makeENV is the cleaned-out environment. Tests must not modify it.
%makeENV = ();
-# %extraENV are any extra environment variables the tests might want to set.
-# These are RESET AFTER EVERY TEST!
-%extraENV = ();
-
sub vms_get_process_logicals {
# Sorry for the long note here, but to keep this test running on
# VMS, it is needed to be understood.
@@ -150,11 +146,6 @@ sub resetENV
}
}
}
-
- foreach $v (keys %extraENV) {
- $ENV{$v} = $extraENV{$v};
- delete $extraENV{$v};
- }
}
sub toplevel
@@ -1059,15 +1050,13 @@ sub _run_with_timeout
# This runs a command without any debugging info.
sub _run_command
{
- # We reset this before every invocation. On Windows I think there is only
- # one environment, not one per process, so I think that variables set in
- # test scripts might leak into subsequent tests if this isn't reset--???
- resetENV();
-
my $orig = $SIG{ALRM};
my $code = eval { _run_with_timeout(@_); };
$SIG{ALRM} = $orig;
+ # Reset then environment so that it's clean for the next test.
+ resetENV();
+
if ($@) {
# The eval failed. If it wasn't SIGALRM then die.
$@ eq "timeout\n" or die "Command failed: $@";