From: Karen Etheridge Date: Wed, 14 Aug 2013 00:15:52 +0000 (-0700) Subject: convert all uses of Test::Exception to Test::Fatal X-Git-Tag: 5.90050~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=2a56ace924b296189e0bf5864d6a3b92809fef66;hp=5a4ce75eb7c71dc6d3190a2377d4aef3abd10c78 convert all uses of Test::Exception to Test::Fatal --- diff --git a/Makefile.PL b/Makefile.PL index 548e7b3..cf8dfb8 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -76,7 +76,7 @@ requires 'URI' => '1.36'; # depreciation transition requires 'Catalyst::DispatchType::Regex' => '5.90021'; -test_requires 'Test::Exception'; +test_requires 'Test::Fatal'; test_requires 'Test::More' => '0.88'; test_requires 'Data::Dump'; test_requires 'HTTP::Request::Common'; diff --git a/t/aggregate/c3_appclass_bug.t b/t/aggregate/c3_appclass_bug.t index 0e5f7ed..e7b44a4 100644 --- a/t/aggregate/c3_appclass_bug.t +++ b/t/aggregate/c3_appclass_bug.t @@ -21,10 +21,10 @@ use Test::More tests => 1; /; } -use Test::Exception; -lives_ok { +use Test::Fatal; +is exception { TestAppC3ErrorUseMoose->setup(); -} 'No C3 error'; +}, undef, 'No C3 error'; 1; diff --git a/t/aggregate/caf_backcompat.t b/t/aggregate/caf_backcompat.t index 27d8fa9..0523134 100644 --- a/t/aggregate/caf_backcompat.t +++ b/t/aggregate/caf_backcompat.t @@ -1,7 +1,6 @@ use strict; use warnings; use Test::More; -use Test::Exception; use Class::MOP (); use Moose::Util (); diff --git a/t/aggregate/error_page_dump.t b/t/aggregate/error_page_dump.t index 099f8da..6cec423 100644 --- a/t/aggregate/error_page_dump.t +++ b/t/aggregate/error_page_dump.t @@ -1,15 +1,15 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use Catalyst::Engine; my $m = sub { Catalyst::Engine->_dump_error_page_element(@_) }; -lives_ok { $m->('Scalar' => ['foo' => 'bar']) }; -lives_ok { $m->('Array' => ['foo' => []]) }; -lives_ok { $m->('Hash' => ['foo' => {}]) }; +is exception { $m->('Scalar' => ['foo' => 'bar']) }, undef; +is exception { $m->('Array' => ['foo' => []]) }, undef; +is exception { $m->('Hash' => ['foo' => {}]) }, undef; done_testing; diff --git a/t/aggregate/meta_method_unneeded.t b/t/aggregate/meta_method_unneeded.t index f52a9b4..5678e94 100644 --- a/t/aggregate/meta_method_unneeded.t +++ b/t/aggregate/meta_method_unneeded.t @@ -3,7 +3,6 @@ use warnings; use FindBin qw/$Bin/; use lib "$Bin/../lib"; use Test::More tests => 1; -use Test::Exception; use Carp (); # Doing various silly things, like for example diff --git a/t/aggregate/unit_core_script_cgi.t b/t/aggregate/unit_core_script_cgi.t index 697f2ad..6a36dbc 100644 --- a/t/aggregate/unit_core_script_cgi.t +++ b/t/aggregate/unit_core_script_cgi.t @@ -6,14 +6,14 @@ use FindBin qw/$Bin/; use lib "$Bin/../lib"; use Test::More; -use Test::Exception; +use Test::Fatal; use Catalyst::Script::CGI; local @ARGV; -lives_ok { +is exception { Catalyst::Script::CGI->new_with_options(application_name => 'TestAppToTestScripts')->run; -} "new_with_options"; +}, undef, "new_with_options"; shift @TestAppToTestScripts::RUN_ARGS; my $server = pop @TestAppToTestScripts::RUN_ARGS; like ref($server), qr/^Plack::Handler/, 'Is a Plack::Handler'; diff --git a/t/aggregate/unit_core_script_create.t b/t/aggregate/unit_core_script_create.t index d492fd9..de09187 100644 --- a/t/aggregate/unit_core_script_create.t +++ b/t/aggregate/unit_core_script_create.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use FindBin qw/$Bin/; use lib "$Bin/../lib"; @@ -41,9 +41,9 @@ use lib "$Bin/../lib"; { local $TestCreateScript::help; local @ARGV; - lives_ok { + is exception { TestCreateScript->new_with_options(application_name => 'TestAppToTestScripts', helper_class => 'TestHelperClass')->run; - } "no argv"; + }, undef, "no argv"; ok $TestCreateScript::help, 'Exited with usage info'; } { @@ -51,9 +51,9 @@ use lib "$Bin/../lib"; local @ARGV = 'foo'; local @TestHelperClass::ARGS; local %TestHelperClass::p; - lives_ok { + is exception { TestCreateScript->new_with_options(application_name => 'TestAppToTestScripts', helper_class => 'TestHelperClass')->run; - } "with argv"; + }, undef, "with argv"; ok !$TestCreateScript::help, 'Did not exit with usage into'; is_deeply \@TestHelperClass::ARGS, ['TestAppToTestScripts', 'foo'], 'Args correct'; is_deeply \%TestHelperClass::p, { '.newfiles' => 1, mech => undef }, 'Params correct'; @@ -64,9 +64,9 @@ use lib "$Bin/../lib"; local @ARGV = 'foo'; local @TestHelperClass::ARGS; local %TestHelperClass::p; - lives_ok { + is exception { TestCreateScript->new_with_options(application_name => 'TestAppToTestScripts', helper_class => 'TestHelperClass::False')->run; - } "with argv"; + }, undef, "with argv"; ok $TestCreateScript::help, 'Did exit with usage into as mk_component returned false'; is_deeply \@TestHelperClass::ARGS, ['TestAppToTestScripts', 'foo'], 'Args correct'; is_deeply \%TestHelperClass::p, { '.newfiles' => 1, mech => undef }, 'Params correct'; diff --git a/t/aggregate/unit_core_script_fastcgi.t b/t/aggregate/unit_core_script_fastcgi.t index 93f1c16..80a8068 100644 --- a/t/aggregate/unit_core_script_fastcgi.t +++ b/t/aggregate/unit_core_script_fastcgi.t @@ -5,7 +5,7 @@ use FindBin qw/$Bin/; use lib "$Bin/../lib"; use Test::More; -use Test::Exception; +use Test::Fatal; use Catalyst::Script::FastCGI; @@ -32,9 +32,9 @@ sub testOption { local @ARGV = @$argstring; local @TestAppToTestScripts::RUN_ARGS; - lives_ok { + is exception { TestFastCGIScript->new_with_options(application_name => 'TestAppToTestScripts')->run; - } "new_with_options"; + }, undef, "new_with_options"; # First element of RUN_ARGS will be the script name, which we don't care about shift @TestAppToTestScripts::RUN_ARGS; diff --git a/t/aggregate/unit_core_script_help.t b/t/aggregate/unit_core_script_help.t index 00d24da..64ac28c 100644 --- a/t/aggregate/unit_core_script_help.t +++ b/t/aggregate/unit_core_script_help.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; -use Test::Exception; +use Test::Fatal; use FindBin qw/$Bin/; use lib "$Bin/../lib"; @@ -21,9 +21,9 @@ test('-?'); sub test { local $TestHelpScript::help; local @ARGV = (@_); - lives_ok { + is exception { TestHelpScript->new_with_options(application_name => 'TestAppToTestScripts')->run; - } 'Lives'; + }, undef, 'Lives'; ok $TestHelpScript::help, 'Got help'; } diff --git a/t/aggregate/unit_core_scriptrunner.t b/t/aggregate/unit_core_scriptrunner.t index 763ddec..5e44ebe 100644 --- a/t/aggregate/unit_core_scriptrunner.t +++ b/t/aggregate/unit_core_scriptrunner.t @@ -2,7 +2,7 @@ use strict; use warnings; use Test::More; use FindBin qw/$Bin/; -use Test::Exception; +use Test::Fatal; use lib "$Bin/../lib"; use_ok('Catalyst::ScriptRunner'); @@ -15,8 +15,8 @@ is Catalyst::ScriptRunner->run('ScriptTestApp', 'Baz'), 'mooCatalyst::Script::Ba 'Script existing only in Catalyst'; # +1 test for the params passed to new_with_options in t/lib/Catalyst/Script/Baz.pm -throws_ok(sub { +like exception { Catalyst::ScriptRunner->run('ScriptTestApp', 'CompileTest'); -}, qr/Couldn't load class/); +}, qr/Couldn't load class/; done_testing; diff --git a/t/aggregate/unit_core_setup_log.t b/t/aggregate/unit_core_setup_log.t index e2dba17..fb73297 100644 --- a/t/aggregate/unit_core_setup_log.t +++ b/t/aggregate/unit_core_setup_log.t @@ -2,7 +2,6 @@ use strict; use warnings; use Test::More tests => 30; -use Test::Exception; use Catalyst (); diff --git a/t/aggregate/unit_load_catalyst_test.t b/t/aggregate/unit_load_catalyst_test.t index 68dfbdf..a39498b 100644 --- a/t/aggregate/unit_load_catalyst_test.t +++ b/t/aggregate/unit_load_catalyst_test.t @@ -8,7 +8,7 @@ use FindBin qw/$Bin/; use lib "$Bin/../lib"; use Catalyst::Utils; use HTTP::Request::Common; -use Test::Exception; +use Test::Fatal; my $Class = 'Catalyst::Test'; my $App = 'TestApp'; @@ -88,7 +88,7 @@ use Catalyst::Test (); ok( $c->stash, " Stash accessible" ); ok( $c->action, " Action object accessible" ); ok( $res->request, " Response has request object" ); - lives_and { is( $res->request->uri, $Url) } + is exception { is( $res->request->uri, $Url) }, undef, " Request object has correct url"; } } } @@ -146,12 +146,12 @@ sub customize { Catalyst::Test::_customize_request($_[0], {}, @_[1 .. $#_]) } use_ok('Catalyst::Test', 'TestApp', 'foobar'); # Back compat test, ensure that request ignores anything which isn't a hash. -lives_ok { +is exception { request(GET('/dummy'), 'foo'); -} 'scalar additional param to request method ignored'; -lives_ok { +}, undef, 'scalar additional param to request method ignored'; +is exception { request(GET('/dummy'), []); -} 'array additional param to request method ignored'; +}, undef, 'array additional param to request method ignored'; my $res = request(GET('/')); is $res->code, 200, 'Response code 200'; diff --git a/t/aggregate/unit_metaclass_compat_extend_non_moose_controller.t b/t/aggregate/unit_metaclass_compat_extend_non_moose_controller.t index 568a629..07a7daa 100644 --- a/t/aggregate/unit_metaclass_compat_extend_non_moose_controller.t +++ b/t/aggregate/unit_metaclass_compat_extend_non_moose_controller.t @@ -12,9 +12,9 @@ use Catalyst (); package TestApp::Controller::Other; use Moose; use Test::More tests => 1; - use Test::Exception; - lives_ok { + use Test::Fatal; + is exception { extends 'TestApp::Controller::Base'; - }; + }, undef; } diff --git a/t/aggregate/unit_metaclass_compat_non_moose_controller.t b/t/aggregate/unit_metaclass_compat_non_moose_controller.t index 1672a18..8036be4 100644 --- a/t/aggregate/unit_metaclass_compat_non_moose_controller.t +++ b/t/aggregate/unit_metaclass_compat_non_moose_controller.t @@ -5,7 +5,7 @@ use FindBin; use lib "$FindBin::Bin/../lib"; use Test::More tests => 1; -use Test::Exception; +use Test::Fatal; use TestAppNonMooseController; # Metaclass init order causes fail. @@ -13,7 +13,7 @@ use TestAppNonMooseController; # f2391d17574eff81d911b97be15ea51080500003 # after which the evil kludge in core can die in a fire. -lives_ok { +is exception { TestAppNonMooseController::ControllerBase->get_action_methods -} 'Base class->get_action_methods ok when sub class initialized first'; +}, undef, 'Base class->get_action_methods ok when sub class initialized first'; diff --git a/t/custom_exception_class_simple.t b/t/custom_exception_class_simple.t index 24983fa..d11bbd3 100644 --- a/t/custom_exception_class_simple.t +++ b/t/custom_exception_class_simple.t @@ -5,16 +5,16 @@ use warnings; use FindBin qw/$Bin/; use lib "$Bin/lib"; use Test::More tests => 2; -use Test::Exception; +use Test::Fatal; -lives_ok { +is exception { require TestAppClassExceptionSimpleTest; -} 'Can load application'; +}, undef, 'Can load application'; -lives_ok { +is exception { Catalyst::Exception->throw -} 'throw is properly stubbed out'; +}, undef, 'throw is properly stubbed out'; diff --git a/t/lib/TestAppPluginWithConstructor.pm b/t/lib/TestAppPluginWithConstructor.pm index 3d0d552..faa1f9c 100644 --- a/t/lib/TestAppPluginWithConstructor.pm +++ b/t/lib/TestAppPluginWithConstructor.pm @@ -1,7 +1,7 @@ # See t/plugin_new_method_backcompat.t package TestAppPluginWithConstructor; use Test::More; -use Test::Exception; +use Test::Fatal; use Catalyst qw/+TestPluginWithConstructor/; use Moose; extends qw/Catalyst/; @@ -9,9 +9,9 @@ extends qw/Catalyst/; __PACKAGE__->setup; our $MODIFIER_FIRED = 0; -lives_ok { +is exception { before 'dispatch' => sub { $MODIFIER_FIRED = 1 } -} 'Can apply method modifier'; +}, undef, 'Can apply method modifier'; no Moose; our $IS_IMMUTABLE_YET = __PACKAGE__->meta->is_immutable; diff --git a/t/plugin_new_method_backcompat.t b/t/plugin_new_method_backcompat.t index 07de6d9..28455fb 100644 --- a/t/plugin_new_method_backcompat.t +++ b/t/plugin_new_method_backcompat.t @@ -9,7 +9,6 @@ # Also tests method modifiers and etc in MyApp.pm still work as expected. use Test::More; -use Test::Exception; use Moose::Util qw/find_meta/; use FindBin; use lib "$FindBin::Bin/lib"; diff --git a/t/psgi_file_testapp_engine_plackup_compat.t b/t/psgi_file_testapp_engine_plackup_compat.t index 3578c6c..4f5a2ea 100644 --- a/t/psgi_file_testapp_engine_plackup_compat.t +++ b/t/psgi_file_testapp_engine_plackup_compat.t @@ -4,7 +4,7 @@ use FindBin qw/$Bin/; use lib "$Bin/lib"; use Test::More; -use Test::Exception; +use Test::Fatal; use Plack::Test; use TestApp; use HTTP::Request::Common; @@ -23,7 +23,7 @@ like $warning, qr/You are running Catalyst\:\:Engine\:\:PSGI/, test_psgi $app, sub { my $cb = shift; - lives_ok { + is exception { my $TIMEOUT_IN_SECONDS = 5; local $SIG{ALRM} = sub { die "alarm\n" }; alarm($TIMEOUT_IN_SECONDS); @@ -34,7 +34,7 @@ test_psgi $app, sub { alarm(0); 1 - } q{app didn't die or timeout}; + }, undef, q{app didn't die or timeout}; }; done_testing; diff --git a/t/unit_core_script_test.t b/t/unit_core_script_test.t index 1328bde..61db9c0 100644 --- a/t/unit_core_script_test.t +++ b/t/unit_core_script_test.t @@ -6,7 +6,7 @@ use FindBin qw/$Bin/; use lib "$Bin/lib"; use Test::More; -use Test::Exception; +use Test::Fatal; use Catalyst::Script::Test; use File::Temp qw/tempfile/; @@ -28,9 +28,9 @@ sub run_test { { local @ARGV = ($url); my $i; - lives_ok { + is exception { $i = Catalyst::Script::Test->new_with_options(application_name => 'TestApp'); - } "new_with_options"; + }, undef, "new_with_options"; ok $i; my $saved; open( $saved, '>&'. STDOUT->fileno )