summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog13
-rw-r--r--tests/scripts/features/export8
-rw-r--r--tests/scripts/functions/eval4
-rw-r--r--tests/scripts/functions/origin2
-rw-r--r--tests/scripts/options/dash-e2
-rw-r--r--tests/scripts/variables/SHELL13
-rw-r--r--tests/test_driver.pl49
7 files changed, 65 insertions, 26 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index a7ceaaa..ee3bab5 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,16 @@
+2005-07-08 Paul D. Smith <psmith@gnu.org>
+
+ * test_driver.pl: Reset the environment to a clean value every
+ time before we invoke make. I'm suspicious that the environment
+ isn't handled the same way in Windows as it is in UNIX, and some
+ variables are leaking out beyond the tests they are intended for.
+ Create an %extraENV hash tests can set to add more env. vars.
+ * tests/scripts/features/export: Change to use %extraENV.
+ * tests/scripts/functions/eval: Ditto.
+ * tests/scripts/functions/origin: Ditto.
+ * tests/scripts/options/dash-e: Ditto.
+ * tests/scripts/variables/SHELL: Ditto.
+
2005-06-27 Paul D. Smith <psmith@gnu.org>
* scripts/options/dash-W: Use 'echo >>' instead of touch to update
diff --git a/tests/scripts/features/export b/tests/scripts/features/export
index 1690ee8..38efe11 100644
--- a/tests/scripts/features/export
+++ b/tests/scripts/features/export
@@ -56,7 +56,7 @@ FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
# TEST 1: make sure vars inherited from the parent are exported
-$ENV{FOO} = 1;
+$extraENV{FOO} = 1;
&run_make_with_options($makefile,"",&get_logfile,0);
@@ -65,8 +65,6 @@ FOO=foo BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n";
&compare_output($answer,&get_logfile(1));
-delete $ENV{FOO};
-
# TEST 2: global export. Explicit unexport takes precedence.
&run_make_with_options($makefile,"EXPORT_ALL=1",&get_logfile,0);
@@ -237,14 +235,12 @@ EOF
close(MAKEFILE);
-@ENV{qw(A B C D E F G H I J)} = qw(1 2 3 4 5 6 7 8 9 10);
+@extraENV{qw(A B C D E F G H I J)} = qw(1 2 3 4 5 6 7 8 9 10);
&run_make_with_options($makefile5,"",&get_logfile,0);
$answer = "A= B= C= D= E= F= G= H= I= J=\n";
&compare_output($answer,&get_logfile(1));
-delete @ENV{qw(A B C D E F G H I J)};
-
# This tells the test driver that the perl test script executed properly.
1;
diff --git a/tests/scripts/functions/eval b/tests/scripts/functions/eval
index bc43053..9595d4e 100644
--- a/tests/scripts/functions/eval
+++ b/tests/scripts/functions/eval
@@ -127,13 +127,11 @@ EOF
close(MAKEFILE);
-$ENV{EVAR} = '1';
+$extraENV{EVAR} = '1';
&run_make_with_options($makefile4, "", &get_logfile);
$answer = "OK\n";
&compare_output($answer,&get_logfile(1));
-delete $ENV{EVAR};
-
# Clean out previous information to allow new run_make_test() interface.
# If we ever convert all the above to run_make_test() we can remove this line.
diff --git a/tests/scripts/functions/origin b/tests/scripts/functions/origin
index d5116cd..49e6f38 100644
--- a/tests/scripts/functions/origin
+++ b/tests/scripts/functions/origin
@@ -16,7 +16,7 @@ defined per the following list:
'automatic' Automatic variable\n";
# Set an environment variable
-$ENV{MAKETEST} = 1;
+$extraENV{MAKETEST} = 1;
open(MAKEFILE,"> $makefile");
diff --git a/tests/scripts/options/dash-e b/tests/scripts/options/dash-e
index 472270d..17c3fc8 100644
--- a/tests/scripts/options/dash-e
+++ b/tests/scripts/options/dash-e
@@ -4,7 +4,7 @@ $description = "The following test creates a makefile to ...";
$details = "";
-$ENV{GOOGLE} = 'boggle';
+$extraENV{GOOGLE} = 'boggle';
open(MAKEFILE,"> $makefile");
diff --git a/tests/scripts/variables/SHELL b/tests/scripts/variables/SHELL
index 93c1872..adfa5b1 100644
--- a/tests/scripts/variables/SHELL
+++ b/tests/scripts/variables/SHELL
@@ -4,15 +4,16 @@ $description = "Test proper handling of SHELL.";
# Find the default value when SHELL is not set. On UNIX it will be /bin/sh,
# but on other platforms who knows?
-$oshell = $ENV{SHELL};
+resetENV();
delete $ENV{SHELL};
$mshell = `echo 'all:;\@echo \$(SHELL)' | $make_path -f-`;
chop $mshell;
# According to POSIX, the value of SHELL in the environment has no impact on
# the value in the makefile.
+# Note %extraENV takes precedence over the default value for the shell.
-$ENV{SHELL} = '/dev/null';
+$extraENV{SHELL} = '/dev/null';
run_make_test('all:;@echo "$(SHELL)"', '', $mshell);
# According to POSIX, any value of SHELL set in the makefile should _NOT_ be
@@ -21,7 +22,7 @@ run_make_test('all:;@echo "$(SHELL)"', '', $mshell);
# all when $(SHELL) is perl :-/. So, we just add an extra initial / and hope
# for the best on non-UNIX platforms :-/.
-$ENV{SHELL} = $mshell;
+$extraENV{SHELL} = $mshell;
run_make_test("SHELL := /$mshell\n".'
all:;@echo "$(SHELL) $$SHELL"
@@ -30,6 +31,8 @@ all:;@echo "$(SHELL) $$SHELL"
# As a GNU make extension, if make's SHELL variable is explicitly exported,
# then we really _DO_ export it.
+$extraENV{SHELL} = $mshell;
+
run_make_test("export SHELL := /$mshell\n".'
all:;@echo "$(SHELL) $$SHELL"
', '', "/$mshell /$mshell");
@@ -38,10 +41,14 @@ all:;@echo "$(SHELL) $$SHELL"
# Test out setting of SHELL, both exported and not, as a target-specific
# variable.
+$extraENV{SHELL} = $mshell;
+
run_make_test("all: SHELL := /$mshell\n".'
all:;@echo "$(SHELL) $$SHELL"
', '', "/$mshell $mshell");
+$extraENV{SHELL} = $mshell;
+
run_make_test("all: export SHELL := /$mshell\n".'
all:;@echo "$(SHELL) $$SHELL"
', '', "/$mshell $mshell");
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;