Commit | Line | Data |
fbcc39ad |
1 | #!perl\r |
2 | \r |
3 | use strict;\r |
4 | use warnings;\r |
5 | \r |
6 | use FindBin;\r |
a2e038a1 |
7 | use lib "$FindBin::Bin/lib";\r |
fbcc39ad |
8 | \r |
9 | use Test::More;\r |
10 | use Catalyst::Test 'TestApp';\r |
11 | use Catalyst::Request;\r |
12 | use Config;\r |
7a2005ce |
13 | use HTTP::Response;\r |
fbcc39ad |
14 | \r |
ae6eea2d |
15 | plan skip_all => 'set TEST_THREADS to enable this test'\r |
16 | unless $ENV{TEST_THREADS};\r |
17 | \r |
fbcc39ad |
18 | if ( $Config{useithreads} && !$ENV{CATALYST_SERVER} ) {\r |
19 | require threads;\r |
20 | plan tests => 3;\r |
21 | }\r |
22 | else {\r |
23 | if ( $ENV{CATALYST_SERVER} ) {\r |
24 | plan skip_all => 'Using remote server';\r |
25 | }\r |
26 | else {\r |
27 | plan skip_all => 'Needs a Perl with ithreads enabled';\r |
28 | }\r |
29 | }\r |
30 | \r |
31 | no warnings 'redefine';\r |
32 | sub request {\r |
33 | my $thr = threads->new( \r |
7a2005ce |
34 | sub { Catalyst::Test::local_request('TestApp',@_) },\r |
fbcc39ad |
35 | @_ \r |
36 | );\r |
37 | $thr->join;\r |
38 | }\r |
39 | \r |
40 | # test that running inside a thread works ok\r |
41 | {\r |
42 | my @expected = qw[\r |
43 | TestApp::Controller::Action::Default->begin\r |
44 | TestApp::Controller::Action::Default->default\r |
45 | TestApp::View::Dump::Request->process\r |
b0652c9d |
46 | TestApp->end\r |
fbcc39ad |
47 | ];\r |
48 | \r |
49 | my $expected = join( ", ", @expected );\r |
50 | \r |
51 | ok( my $response = request('http://localhost/action/default'), 'Request' );\r |
52 | ok( $response->is_success, 'Response Successful 2xx' );\r |
53 | is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' );\r |
54 | }\r |