perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Kobes <>
Subject Re: [mp2] directive/setupenv.t test on Win32
Date Sat, 11 Dec 2004 21:35:27 GMT
On Sat, 11 Dec 2004, Stas Bekman wrote:

> Right, to make it a good test we need to know what env var exist but
> wasn't passed. And since in t/directive/setupenv.t we can actually access
> %ENV which should be a complete copy of shell env, it's easier to make a
> more sensible test.
> So for example iterate over SHELL, USER, OS and see what's set in real
> $ENV{} and then check that it's not in %env returned by the server.

Good idea - how about the following:

Index: t/directive/setupenv.t
--- t/directive/setupenv.t	(revision 111576)
+++ t/directive/setupenv.t	(working copy)
@@ -5,8 +5,15 @@
 use Apache::TestRequest;
 use Apache::TestUtil;

-plan tests => 3;
+use constant WIN32 => Apache::TestConfig::WIN32;

+# on Win32, some user environment variables, like HOME, may be passed
+# through (via Apache?) if set, while system environment variables are not.
+my @vars = qw(SHELL USER OS);
+plan tests => 2 + @vars;
 my $location = '/TestDirective__setupenv';

 my $env = GET_BODY $location;
@@ -23,4 +30,11 @@

 ok t_cmp $env{REQUEST_URI}, $location, "testing REQUEST_URI";

-ok not exists $env{HOME};
+foreach my $var(@vars) {
+    if ($ENV{$var}) {
+        ok not exists $env{$var};
+    }
+    else {
+        skip "\$ENV{$var} not set", 0;
+    }

In testing this out on Win32, I found that whether or not an
environment variable gets passed thru is more complicated
than I initially believed. On Windows, at least with recent
flavours, there's "system" environment variables, and then
there's environment variables a user may set. The user
environment variables, if they're set, get passed thru
(that's why I was seeing $ENV{HOME}). However, "system"
environment variables, like OS used in the above test, don't
get passed through. I'm not quite sure of the distinction
between system and user environment variables - that'll
require a better understanding of the relevant Apache
sources, which I'll try.

best regards,

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message