5 use File::Basename qw( dirname );
13 $PLP::use_cache = 0 if $PLP::use_cache;
14 #TODO: caching on (change file names)
16 chdir File::Spec->catdir(dirname($0), '50-cgi')
17 or BAIL_OUT('cannot change to test directory ./50-cgi/');
18 my $ORGDIR = '.'; # Cwd::getcwd();
20 # 0*: permission checks using generated dummy files
22 for my $file (glob '0*.html') {
23 $file =~ s/[.]html$/.plp/;
24 my ($mode) = $file =~ /^..-(\d*)\b/;
27 return 1; # do not create
31 open my $out, '>', $file or die "cannot generate source file ($!)\n";
35 chmod 0244, $file or die "cannot change permissions ($!)\n";
39 } or chomp $@, skip("$file: $@", 1); # ignore generation failure
42 eval { unlink $file }; # clean up
45 # 1*-2*: generic tests with standard environment
46 plp_ok($_) for glob '[12]*.html';
48 # 3*: error tests depending on warning message
50 my @inctests = glob '3*.html';
52 my $INCFILE = File::Spec->rel2abs("$ORGDIR/missinginclude");
53 if (open my $dummy, "<", $INCFILE) { # like PLP::source will
54 fail("file missinginclude shouldn't exist");
55 skip("missinginclude tests (3*)", @inctests - 1);
57 my $INCWARN = qq{Can't open "$INCFILE" ($!)};
59 plp_ok($_, INCWARN => $INCWARN) for @inctests;
62 # 4*-6*: apache environment (default)
63 plp_ok($_) for glob '[4-6]*.html';
70 local $TODO = 'future feature';
72 CONTENT_TYPE => 'multipart/form-data; boundary=knip',
73 }) for glob '7*.html';
76 # 8*: lighttpd environment
78 # lighttpd/1.4.7 CGI environment
79 REQUEST_METHOD => 'GET',
80 REQUEST_URI => "/$_/test/123",
81 QUERY_STRING => 'test=1&test=2',
82 GATEWAY_INTERFACE => 'CGI/1.1',
84 SCRIPT_NAME => "/$_", #XXX: .plp?
85 SCRIPT_FILENAME => "$ORGDIR/$_",
86 PATH_INFO => '/test/123',
87 PATH_TRANSLATED => undef,
88 DOCUMENT_ROOT => undef,