t: replace variable root directory in tests
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 3 Sep 2015 22:44:01 +0000 (00:44 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 14 Sep 2015 21:40:44 +0000 (23:40 +0200)
Relative path substituted in commit 3.24-3-gaeeb9a5d49 (2015-09-14)
[move i/o testing routines to Test::PLP module] works just as well.

lib/Test/PLP.pm
t/50-cgi.t

index d1ebb4cd4e740fad2298285a69de240303cb0b4b..c030742a137b43b5e5261de76090f11b43c9cb03 100644 (file)
@@ -3,7 +3,6 @@ package Test::PLP;
 use strict;
 use warnings;
 
-use Cwd;
 use PLP::Functions qw( DecodeURI );
 require PLP::Backend::CGI;
 require PerlIO::scalar;
@@ -17,7 +16,6 @@ our @EXPORT = qw( plp_is plp_ok );
 $PLP::use_cache = 0 if $PLP::use_cache;
 #TODO: caching on (change file names)
 
-my $ORGDIR = '.'; # Cwd::getcwd();
 open ORGOUT, '>&', *STDOUT;
 
 sub is_string ($$;$) {
@@ -52,10 +50,10 @@ sub _plp_run {
                GATEWAY_INTERFACE => 'CGI/1.1',
                
                SCRIPT_NAME => '/plp.cgi',
-               SCRIPT_FILENAME => "$ORGDIR/plp.cgi",
+               SCRIPT_FILENAME => "./plp.cgi",
                PATH_INFO => "/$src/test/123",
-               PATH_TRANSLATED => "$ORGDIR/$src/test/123",
-               DOCUMENT_ROOT => $ORGDIR,
+               PATH_TRANSLATED => "./$src/test/123",
+               DOCUMENT_ROOT => ".",
                
                $env ? %{$env} : (),
        ); # Apache/2.2.4 CGI environment
@@ -139,7 +137,7 @@ sub plp_ok {
        $replace{HEAD} //= "Content-Type: text/html\nX-PLP-Version: $PLP::VERSION\n";
        $replace{VERSION        } //= $PLP::VERSION;
        $replace{SCRIPT_NAME    } //= $infile;
-       $replace{SCRIPT_FILENAME} //= "$ORGDIR/$infile";
+       $replace{SCRIPT_FILENAME} //= "./$infile";
 
        chomp $out;
        $out =~ s/\$$_/$replace{$_}/g for keys %replace;
index 09ebd0b1dc1be03cb37c682fbdaed12392b3d71d..ed39da5a1fc38f53c176a885d357c16383287f4e 100644 (file)
@@ -1,7 +1,6 @@
 use strict;
 use warnings;
 
-use Cwd;
 use File::Basename qw( dirname );
 use File::Spec;
 use Test::More tests => 25;
@@ -13,7 +12,6 @@ $PLP::use_cache = 0 if $PLP::use_cache;
 
 chdir File::Spec->catdir(dirname($0), '50-cgi')
        or BAIL_OUT('cannot change to test directory ./50-cgi/');
-my $ORGDIR = '.'; # Cwd::getcwd();
 
 # 0*: permission checks using generated dummy files
 SKIP:
@@ -47,7 +45,7 @@ plp_ok($_) for glob '[12]*.html';
 SKIP: {
        my @inctests = glob '3*.html';
 
-       my $INCFILE = File::Spec->rel2abs("$ORGDIR/missinginclude");
+       my $INCFILE = File::Spec->rel2abs("./missinginclude");
        if (open my $dummy, "<", $INCFILE) {  # like PLP::source will
                fail("file missinginclude shouldn't exist");
                skip("missinginclude tests (3*)", @inctests - 1);
@@ -80,7 +78,7 @@ plp_ok($_, -env => {
        GATEWAY_INTERFACE => 'CGI/1.1',
        
        SCRIPT_NAME => "/$_", #XXX: .plp?
-       SCRIPT_FILENAME => "$ORGDIR/$_",
+       SCRIPT_FILENAME => "./$_",
        PATH_INFO => '/test/123',
        PATH_TRANSLATED => undef,
        DOCUMENT_ROOT => undef,