git.shiar.nl
/
perl
/
plp
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7e698b4
)
t/50-cgi: reset environment for each test
author
Mischa POSLAWSKY
<perl@shiar.org>
Mon, 20 Feb 2012 04:54:54 +0000
(
05:54
+0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Tue, 19 Nov 2013 00:53:37 +0000
(
01:53
+0100)
Explicit %ENV for each test to avoid mistakes and allow for independent tests.
t/50-cgi.t
patch
|
blob
|
history
diff --git
a/t/50-cgi.t
b/t/50-cgi.t
index 58e36d16c108ac5b9b996de38a7619e87049b7c3..d6c2856de5a6162f35cf4d95c331f3dd5d243c8e 100644
(file)
--- a/
t/50-cgi.t
+++ b/
t/50-cgi.t
@@
-37,10
+37,25
@@
not -f "$base/$testfile" or BAIL_OUT("$testfile exists");
open ORGOUT, '>&', *STDOUT;
sub plp_is {
open ORGOUT, '>&', *STDOUT;
sub plp_is {
- my ($test, $plp, $expect) = @_;
+ my ($test, $plp, $expect
, $env
) = @_;
chomp $expect;
local $Test::Builder::Level = $Test::Builder::Level + 1;
chomp $expect;
local $Test::Builder::Level = $Test::Builder::Level + 1;
+ %ENV = (
+ REQUEST_METHOD => 'GET',
+ REQUEST_URI => "/$testfile/test/123",
+ QUERY_STRING => 'test=1&test=2',
+ GATEWAY_INTERFACE => 'CGI/1.1',
+
+ SCRIPT_NAME => '/plp.cgi',
+ SCRIPT_FILENAME => "$base/plp.cgi",
+ PATH_INFO => "/$testfile/test/123",
+ PATH_TRANSLATED => "$base/$testfile/test/123",
+ DOCUMENT_ROOT => $base,
+
+ $env ? %{$env} : (),
+ ); # Apache/2.2.4 CGI environment
+
if (defined $plp) {
eval {
open my $testfh, '>', "$base/$testfile" or die $!;
if (defined $plp) {
eval {
open my $testfh, '>', "$base/$testfile" or die $!;
@@
-86,19
+101,6
@@
sub getwarning {
return $res;
};
return $res;
};
-%ENV = (
- REQUEST_METHOD => 'GET',
- REQUEST_URI => "/$testfile/test/123",
- QUERY_STRING => 'test=1&test=2',
- GATEWAY_INTERFACE => 'CGI/1.1',
-
- SCRIPT_NAME => '/plp.cgi',
- SCRIPT_FILENAME => "$base/plp.cgi",
- PATH_INFO => "/$testfile/test/123",
- PATH_TRANSLATED => "$base/$testfile/test/123",
- DOCUMENT_ROOT => $base,
-); # Apache/2.2.4 CGI environment
-
my $HEAD = <<EOT; # common header output
Content-Type: text/html
X-PLP-Version: $PLP::VERSION
my $HEAD = <<EOT; # common header output
Content-Type: text/html
X-PLP-Version: $PLP::VERSION
@@
-223,8
+225,8
@@
TEST
chmod 0644, $testfile;
}
chmod 0644, $testfile;
}
-
$ENV{PATH_TRANSLATED} = "$base/missinginclude/test/123"
;
-plp_is('not found', undef, <<TEST);
+
my %nf = (PATH_TRANSLATED => "$base/missinginclude/test/123")
;
+plp_is('not found', undef, <<TEST
, \%nf
);
<warning>PLP: Not found: $base/missinginclude/test/123 (/$testfile/test/123)</warning>
Content-Type: text/html
Status: 404
<warning>PLP: Not found: $base/missinginclude/test/123 (/$testfile/test/123)</warning>
Content-Type: text/html
Status: 404
@@
-239,7
+241,8
@@
The requested URL /$testfile/test/123 was not found on this server.<p>
</body></html>
TEST
</body></html>
TEST
-%ENV = (
+plp_is('%ENV on lighttpd', @envtest, {
+ # lighttpd/1.4.7 CGI environment
REQUEST_METHOD => 'GET',
REQUEST_URI => "/$testfile/test/123",
QUERY_STRING => 'test=1&test=2',
REQUEST_METHOD => 'GET',
REQUEST_URI => "/$testfile/test/123",
QUERY_STRING => 'test=1&test=2',
@@
-248,9
+251,9
@@
TEST
SCRIPT_NAME => "/$testfile", #XXX: .plp?
SCRIPT_FILENAME => "$base/$testfile",
PATH_INFO => '/test/123',
SCRIPT_NAME => "/$testfile", #XXX: .plp?
SCRIPT_FILENAME => "$base/$testfile",
PATH_INFO => '/test/123',
-); # lighttpd/1.4.7 CGI environment
-
-
plp_is('%ENV on lighttpd', @envtest
);
+ PATH_TRANSLATED => undef,
+ DOCUMENT_ROOT => undef,
+
}
);
unlink "$base/$testfile";
unlink "$base/$testfile";