support CRLF in tests
[catagits/Catalyst-Controller-WrapCGI.git] / t / cgibin.t
index e62b1b1..0e8179d 100644 (file)
@@ -10,7 +10,12 @@ use Test::More;
 use HTTP::Request::Common;
 
 my %orig_sig;
-BEGIN { %orig_sig = %SIG; }
+BEGIN {
+    %orig_sig = %SIG;
+# perl < 5.8.9 won't set a %SIG entry to undef, it sets it to ''
+    %orig_sig = map { defined $_ ? $_ : '' } %orig_sig
+        if $] < 5.008009;
+}
 
 use Catalyst::Test 'TestCGIBin';
 
@@ -18,7 +23,6 @@ use Catalyst::Test 'TestCGIBin';
 $ENV{MOD_PERL} = "mod_perl/2.0";
 
 is_deeply \%SIG, \%orig_sig, '%SIG is preserved on compile';
-%SIG = %orig_sig;
 
 my $response = request POST '/my-bin/path/test.pl', [
     foo => 'bar',
@@ -45,6 +49,10 @@ $response = request POST '/my-bin/exit.pl', [
 
 is($response->code, 500, 'POST to Perl CGI with nonzero exit()');
 
+$response = request '/my-bin/ignored.cgi';
+
+is($response->code, 500, "file not matching 'cgi_file_pattern' is ignored");
+
 $response = request POST '/cgihandler/mtfnpy', [
     foo => 'bar',
     bar => 'baz'
@@ -54,7 +62,7 @@ is($response->content, 'foo:bar bar:baz',
     'POST to Perl CGI File through a forward via cgi_action');
 
 $response = request '/my-bin/path/testdata.pl';
-is($response->content, "testing\n",
+like($response->content, qr/^testing\r?\n\z/,
     'scripts with __DATA__ sections work');
 
 $response = request '/my-bin/pathinfo.pl/path/info';
@@ -79,4 +87,10 @@ SKIP: {
     is $response->code, 500, 'Non-Perl CGI with non-zero exit dies';
 }
 
+{ $response = get('/my-bin/time.pl');
+  sleep 1;
+  my $response_2 =  get('/my-bin/time.pl');
+  isnt( $response, $response_2, 'cgis are getting invoked each time' );
+}
+
 done_testing;