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