From 9038784fd549da6452ab9491eae5d3fd5dd9fa42 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Mon, 20 Feb 2012 05:54:54 +0100 Subject: [PATCH] t/50-cgi: reset environment for each test Explicit %ENV for each test to avoid mistakes and allow for independent tests. --- t/50-cgi.t | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/t/50-cgi.t b/t/50-cgi.t index 58e36d1..d6c2856 100644 --- 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 { - my ($test, $plp, $expect) = @_; + my ($test, $plp, $expect, $env) = @_; 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 $!; @@ -86,19 +101,6 @@ sub getwarning { 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 = < "$base/missinginclude/test/123"); +plp_is('not found', undef, <PLP: Not found: $base/missinginclude/test/123 (/$testfile/test/123) Content-Type: text/html Status: 404 @@ -239,7 +241,8 @@ The requested URL /$testfile/test/123 was not found on this server.

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', @@ -248,9 +251,9 @@ TEST 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"; -- 2.30.0