summaryrefslogtreecommitdiff
path: root/tests/test_driver.pl
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2005-07-12 04:35:13 +0000
committerPaul Smith <psmith@gnu.org>2005-07-12 04:35:13 +0000
commit1e9dc3ce45ac44ea51292ca964b52ce47fee3ad3 (patch)
tree8bec287893a5b2fb441be612fbac4d64b8d8c8b2 /tests/test_driver.pl
parent0e30f46a624803455dcc74acf9a333666467d253 (diff)
downloadgunmake-1e9dc3ce45ac44ea51292ca964b52ce47fee3ad3.tar.gz
Various minor updates and code cleanups.
Diffstat (limited to 'tests/test_driver.pl')
-rw-r--r--tests/test_driver.pl49
1 files changed, 37 insertions, 12 deletions
diff --git a/tests/test_driver.pl b/tests/test_driver.pl
index 7cd40b5..4b4e72b 100644
--- a/tests/test_driver.pl
+++ b/tests/test_driver.pl
@@ -32,12 +32,35 @@ $tests_passed = 0;
# Yeesh. This whole test environment is such a hack!
$test_passed = 1;
-sub toplevel
+
+# %makeENV is the cleaned-out environment.
+%makeENV = ();
+
+# %extraENV are any extra environment variables the tests might want to set.
+# These are RESET AFTER EVERY TEST!
+%extraENV = ();
+
+# %origENV is the caller's original environment
+%origENV = %ENV;
+
+sub resetENV
{
- # Get a clean environment
+ # We used to say "%ENV = ();" but this doesn't work in Perl 5.000
+ # through Perl 5.004. It was fixed in Perl 5.004_01, but we don't
+ # want to require that here, so just delete each one individually.
+ foreach $v (keys %ENV) {
+ delete $ENV{$v};
+ }
- %makeENV = ();
+ %ENV = %makeENV;
+ foreach $v (keys %extraENV) {
+ $ENV{$v} = $extraENV{$v};
+ delete $extraENV{$v};
+ }
+}
+sub toplevel
+{
# Pull in benign variables from the user's environment
#
foreach (# UNIX-specific things
@@ -57,15 +80,7 @@ sub toplevel
#
%origENV = %ENV;
- # We used to say "%ENV = ();" but this doesn't work in Perl 5.000
- # through Perl 5.004. It was fixed in Perl 5.004_01, but we don't
- # want to require that here, so just delete each one individually.
-
- foreach $v (keys %ENV) {
- delete $ENV{$v};
- }
-
- %ENV = %makeENV;
+ resetENV();
$| = 1; # unbuffered output
@@ -744,6 +759,11 @@ sub run_command
{
local ($code);
+ # 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();
+
print "\nrun_command: @_\n" if $debug;
$code = system @_;
print "run_command: \"@_\" returned $code.\n" if $debug;
@@ -761,6 +781,11 @@ sub run_command_with_output
local ($filename) = shift;
local ($code);
+ # 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();
+
&attach_default_output ($filename);
$code = system @_;
&detach_default_output;