X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Flive%2Fcomponent%2Fcontroller%2Faction%2Fregexp.t;h=f67d0f9f1df1d40b0ca74eba2ef359cd561a2c6f;hp=6956552e631cf901a41f92d7d8a9fb38aed85884;hb=587b0f5882d4f5e128ae082758da37b065a3efde;hpb=fbcc39ad23f2bbecf5d84c9ba581e6af86fcd460 diff --git a/t/live/component/controller/action/regexp.t b/t/live/component/controller/action/regexp.t index 6956552..f67d0f9 100644 --- a/t/live/component/controller/action/regexp.t +++ b/t/live/component/controller/action/regexp.t @@ -6,24 +6,59 @@ use warnings; use FindBin; use lib "$FindBin::Bin/../../../lib"; -use Test::More tests => 12; -use Catalyst::Test 'TestApp'; +our $iters; + +BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } +use Test::More tests => 12*$iters; +use Catalyst::Test 'TestApp'; -{ - ok( my $response = request('http://localhost/action/regexp/10/hello'), 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content_type, 'text/plain', 'Response Content-Type' ); - is( $response->header('X-Catalyst-Action'), '^action/regexp/(\d+)/(\w+)$', 'Test Action' ); - is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Regexp', 'Test Class' ); - like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' ); +if ( $ENV{CAT_BENCHMARK} ) { + require Benchmark; + Benchmark::timethis( $iters, \&run_tests ); } +else { + for ( 1 .. $iters ) { + run_tests(); + } +} + +sub run_tests { + { + ok( my $response = request('http://localhost/action/regexp/10/hello'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + '^action/regexp/(\d+)/(\w+)$', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Regexp', + 'Test Class' + ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Request' \)$/s, + 'Content is a serialized Catalyst::Request' + ); + } -{ - ok( my $response = request('http://localhost/action/regexp/hello/10'), 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->content_type, 'text/plain', 'Response Content-Type' ); - is( $response->header('X-Catalyst-Action'), '^action/regexp/(\w+)/(\d+)$', 'Test Action' ); - is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Regexp', 'Test Class' ); - like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' ); + { + ok( my $response = request('http://localhost/action/regexp/hello/10'), + 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + '^action/regexp/(\w+)/(\d+)$', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Regexp', + 'Test Class' + ); + like( + $response->content, + qr/^bless\( .* 'Catalyst::Request' \)$/s, + 'Content is a serialized Catalyst::Request' + ); + } }