Commit | Line | Data |
e1bf532b |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin; |
7 | use lib "$FindBin::Bin/../../../lib"; |
8 | |
232fd394 |
9 | our $iters; |
10 | |
11 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } |
12 | |
13 | use Test::More tests => 18*$iters; |
e1bf532b |
14 | use Catalyst::Test 'TestApp'; |
15 | |
51f97d14 |
16 | if ( $ENV{CAT_BENCHMARK} ) { |
17 | require Benchmark; |
232fd394 |
18 | Benchmark::timethis( $iters, \&run_tests ); |
51f97d14 |
19 | |
20 | # new dispatcher: |
21 | # 11 wallclock secs (10.14 usr + 0.20 sys = 10.34 CPU) @ 15.18/s (n=157) |
22 | # old dispatcher (r1486): |
23 | # 11 wallclock secs (10.34 usr + 0.20 sys = 10.54 CPU) @ 13.76/s (n=145) |
24 | } |
25 | else { |
232fd394 |
26 | for ( 1 .. $iters ) { |
51f97d14 |
27 | run_tests(); |
28 | } |
29 | } |
30 | |
31 | sub run_tests { |
b960cfb8 |
32 | # test auto + local method |
33 | { |
34 | my @expected = qw[ |
35 | TestApp::Controller::Action::Auto->begin |
36 | TestApp::Controller::Action::Auto->auto |
37 | TestApp::Controller::Action::Auto->one |
38 | ]; |
39 | |
40 | my $expected = join( ", ", @expected ); |
41 | |
42 | ok( my $response = request('http://localhost/action/auto/one'), 'auto + local' ); |
43 | is( $response->header('X-Catalyst-Executed'), |
44 | $expected, 'Executed actions' ); |
45 | is( $response->content, 'one', 'Content OK' ); |
46 | } |
47 | |
48 | # test auto + default |
49 | { |
50 | my @expected = qw[ |
51 | TestApp::Controller::Action::Auto->begin |
52 | TestApp::Controller::Action::Auto->auto |
53 | TestApp::Controller::Action::Auto->default |
54 | ]; |
55 | |
56 | my $expected = join( ", ", @expected ); |
57 | |
58 | ok( my $response = request('http://localhost/action/auto/anything'), 'auto + default' ); |
59 | is( $response->header('X-Catalyst-Executed'), |
60 | $expected, 'Executed actions' ); |
61 | is( $response->content, 'default', 'Content OK' ); |
62 | } |
63 | |
64 | # test auto + auto + local |
65 | { |
66 | my @expected = qw[ |
67 | TestApp::Controller::Action::Auto::Deep->begin |
68 | TestApp::Controller::Action::Auto->auto |
69 | TestApp::Controller::Action::Auto::Deep->auto |
70 | TestApp::Controller::Action::Auto::Deep->one |
71 | ]; |
72 | |
73 | my $expected = join( ", ", @expected ); |
74 | |
75 | ok( my $response = request('http://localhost/action/auto/deep/one'), 'auto + auto + local' ); |
76 | is( $response->header('X-Catalyst-Executed'), |
77 | $expected, 'Executed actions' ); |
78 | is( $response->content, 'deep one', 'Content OK' ); |
79 | } |
80 | |
81 | # test auto + auto + default |
82 | { |
83 | my @expected = qw[ |
84 | TestApp::Controller::Action::Auto::Deep->begin |
85 | TestApp::Controller::Action::Auto->auto |
86 | TestApp::Controller::Action::Auto::Deep->auto |
87 | TestApp::Controller::Action::Auto::Deep->default |
88 | ]; |
89 | |
90 | my $expected = join( ", ", @expected ); |
91 | |
92 | ok( my $response = request('http://localhost/action/auto/deep/anything'), 'auto + auto + default' ); |
93 | is( $response->header('X-Catalyst-Executed'), |
94 | $expected, 'Executed actions' ); |
95 | is( $response->content, 'deep default', 'Content OK' ); |
96 | } |
97 | |
98 | # test auto + failing auto + local + end |
99 | { |
100 | my @expected = qw[ |
101 | TestApp::Controller::Action::Auto::Abort->begin |
102 | TestApp::Controller::Action::Auto->auto |
103 | TestApp::Controller::Action::Auto::Abort->auto |
104 | TestApp::Controller::Action::Auto::Abort->end |
105 | ]; |
106 | |
107 | my $expected = join( ", ", @expected ); |
108 | |
109 | ok( my $response = request('http://localhost/action/auto/abort/one'), 'auto + failing auto + local' ); |
110 | is( $response->header('X-Catalyst-Executed'), |
111 | $expected, 'Executed actions' ); |
112 | is( $response->content, 'abort end', 'Content OK' ); |
113 | } |
114 | |
115 | # test auto + failing auto + default + end |
116 | { |
117 | my @expected = qw[ |
118 | TestApp::Controller::Action::Auto::Abort->begin |
119 | TestApp::Controller::Action::Auto->auto |
120 | TestApp::Controller::Action::Auto::Abort->auto |
121 | TestApp::Controller::Action::Auto::Abort->end |
122 | ]; |
123 | |
124 | my $expected = join( ", ", @expected ); |
125 | |
126 | ok( my $response = request('http://localhost/action/auto/abort/anything'), 'auto + failing auto + default' ); |
127 | is( $response->header('X-Catalyst-Executed'), |
128 | $expected, 'Executed actions' ); |
129 | is( $response->content, 'abort end', 'Content OK' ); |
130 | } |
e1bf532b |
131 | } |