test %SIG preservation during compile
[catagits/Catalyst-Controller-WrapCGI.git] / t / cgibin.t
CommitLineData
21a20b7e 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin '$Bin';
7use lib "$Bin/lib";
8
d5ba2ab2 9use Test::More;
21a20b7e 10use HTTP::Request::Common;
11
f316e295 12my %orig_sig;
13BEGIN { %orig_sig = %SIG; }
14
15use Catalyst::Test 'TestCGIBin';
16
46a4350c 17# this should be ignored
18$ENV{MOD_PERL} = "mod_perl/2.0";
19
f316e295 20is_deeply \%SIG, \%orig_sig, '%SIG is preserved on compile';
21%SIG = %orig_sig;
22
9cc2dd4c 23my $response = request POST '/my-bin/path/test.pl', [
21a20b7e 24 foo => 'bar',
25 bar => 'baz'
26];
27
28is($response->content, 'foo:bar bar:baz', 'POST to Perl CGI File');
29
06d193b4 30$response = request '/my-bin/path/test.pl?foo=bar&bar=baz';
31
32is($response->content, 'foo:bar bar:baz',
33 'Perl CGI File invoked with query params');
34
bdb35995 35$response = request POST '/my-bin/exit.pl', [
36 name => 'world',
37];
38
39is($response->content, 'hello world', 'POST to Perl CGI with exit()');
40
41$response = request POST '/my-bin/exit.pl', [
42 name => 'world',
43 exit => 17,
44];
45
46is($response->code, 500, 'POST to Perl CGI with nonzero exit()');
47
21a20b7e 48$response = request POST '/cgihandler/mtfnpy', [
49 foo => 'bar',
50 bar => 'baz'
51];
52
53is($response->content, 'foo:bar bar:baz',
54 'POST to Perl CGI File through a forward via cgi_action');
55
63096ad1 56$response = request '/my-bin/path/testdata.pl';
fbaba9dd 57is($response->content, "testing\n",
58 'scripts with __DATA__ sections work');
59
f410f043 60$response = request '/my-bin/pathinfo.pl/path/info';
61is($response->content, '/path/info',
62 'PATH_INFO works');
63
d5ba2ab2 64ok request '/my-bin/sigs.pl';
65
66is_deeply \%SIG, \%orig_sig, '%SIG is preserved';
67
21a20b7e 68SKIP: {
69 skip "Can't run shell scripts on non-*nix", 1
70 if $^O eq 'MSWin32' || $^O eq 'VMS';
71
5709e6bd 72# for some reason the +x is not preserved in the dist
73 system "chmod +x $Bin/lib/TestCGIBin/root/cgi-bin/test.sh";
74
9cc2dd4c 75 is(get('/my-bin/test.sh'), "Hello!\n", 'Non-Perl CGI File');
21a20b7e 76}
d5ba2ab2 77
78done_testing;