From: Karen Etheridge Date: Tue, 26 Oct 2010 20:40:05 +0000 (-0700) Subject: convert all uses of Test::Exception to Test::Fatal. X-Git-Tag: 0.34~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aabf4179f74c8607d8c9de5a1da07a5f2cb48b3b;p=gitmo%2FMooseX-Getopt.git convert all uses of Test::Exception to Test::Fatal. --- diff --git a/ChangeLog b/ChangeLog index 3fe36a4..34c3772 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ Revision history for Perl extension MooseX-Getopt +NEXT + * The test suite now uses Test::Fatal instead of Test::Exception. (Karen + Etheridge) + 0.33 Thu 26 Aug 2010 * Remove Test::Most from newly added test (RT#60766) diff --git a/t/004_nogetop.t b/t/004_nogetop.t index c5c222c..974c6c8 100644 --- a/t/004_nogetop.t +++ b/t/004_nogetop.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More tests => 9; -use Test::Exception 0.21; +use Test::Fatal; BEGIN { use_ok('MooseX::Getopt'); @@ -98,5 +98,5 @@ BEGIN { { local @ARGV = (qw/--private_stuff 317/); - throws_ok { App->new_with_options } qr/Unknown option: private_stuff/; + like exception { App->new_with_options }, qr/Unknown option: private_stuff/; } diff --git a/t/005_strict.t b/t/005_strict.t index dd4c6c3..a5d82c5 100644 --- a/t/005_strict.t +++ b/t/005_strict.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More tests => 10; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('MooseX::Getopt'); @@ -89,12 +89,12 @@ BEGIN { { local @ARGV = (qw/--private_stuff 317/); - throws_ok { App->new_with_options } qr/Unknown option: private_stuff/; + like exception { App->new_with_options }, qr/Unknown option: private_stuff/; } { local @ARGV = (qw/--length 100/); - throws_ok { App->new_with_options } qr/Unknown option: length/; + like exception { App->new_with_options }, qr/Unknown option: length/; } diff --git a/t/007_nogetopt_trait.t b/t/007_nogetopt_trait.t index 5ccef57..0088983 100644 --- a/t/007_nogetopt_trait.t +++ b/t/007_nogetopt_trait.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More tests => 9; -use Test::Exception; +use Test::Fatal; BEGIN { use_ok('MooseX::Getopt'); @@ -98,5 +98,5 @@ BEGIN { { local @ARGV = (qw/--private_stuff 317/); - throws_ok { App->new_with_options } qr/Unknown option: private_stuff/; + like exception { App->new_with_options }, qr/Unknown option: private_stuff/; } diff --git a/t/008_configfromfile.t b/t/008_configfromfile.t index ea3f9b5..1a1d847 100644 --- a/t/008_configfromfile.t +++ b/t/008_configfromfile.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More tests => 37; -use Test::Exception; +use Test::Fatal; use File::Spec; use Test::Requires 0.05 { @@ -86,7 +86,7 @@ use Test::Requires 0.05 { { local @ARGV = qw( --required_from_argv 1 ); - throws_ok { App->new_with_options } qr/Required option missing: required_from_config/; + like exception { App->new_with_options }, qr/Required option missing: required_from_config/; { my $app = App::DefaultConfigFile->new_with_options; @@ -155,7 +155,7 @@ use Test::Requires 0.05 { # Required arg not supplied from cmdline { local @ARGV = qw( --configfile /notused ); - throws_ok { App->new_with_options } qr/Required option missing: required_from_argv/; + like exception { App->new_with_options }, qr/Required option missing: required_from_argv/; } # Config file value overriden from cmdline @@ -204,7 +204,7 @@ use Test::Requires 0.05 { # With DerivedApp, the Getopt role was applied at a different level # than the ConfigFromFile role { - lives_ok { DerivedApp::Getopt->new_with_options } 'Can create DerivedApp'; + ok ! exception { DerivedApp::Getopt->new_with_options }, 'Can create DerivedApp'; } sub app_ok { diff --git a/t/009_gld_and_explicit_options.t b/t/009_gld_and_explicit_options.t index dadceb2..c095bdd 100644 --- a/t/009_gld_and_explicit_options.t +++ b/t/009_gld_and_explicit_options.t @@ -4,7 +4,7 @@ use strict; use warnings; use Test::More tests => 5; -use Test::Exception; +use Test::Fatal; use Test::Requires { 'Getopt::Long::Descriptive' => 0.01, # skip all if not installed @@ -34,9 +34,9 @@ use_ok('MooseX::Getopt'); @ARGV = qw(--bar 10); my $foo; -lives_ok { +ok ! exception { $foo = Testing::Foo->new_with_options(baz => 100); -} '... this should work'; +}, '... this should work'; isa_ok($foo, 'Testing::Foo'); is($foo->bar, 10, '... got the right values'); diff --git a/t/010_dashes.t b/t/010_dashes.t index 52b7849..c605635 100644 --- a/t/010_dashes.t +++ b/t/010_dashes.t @@ -3,9 +3,8 @@ use strict; use warnings; -use Test::More tests => 5; - -use Test::Exception; +use Test::More tests => 7; +use Test::Fatal; BEGIN { @@ -24,20 +23,20 @@ BEGIN { { local @ARGV = (qw/--some-thingy bar/); - lives_and { is( App->new_with_options->some_thingy, 'bar') } 'Dash in option name'; + ok ! exception { is( App->new_with_options->some_thingy, 'bar') }, 'Dash in option name'; } { local @ARGV = (qw/--some_thingy bar/); - throws_ok { App->new_with_options } qr/Unknown option: some_thingy/; + like exception { App->new_with_options }, qr/Unknown option: some_thingy/; } { local @ARGV = (qw/--another_thingy bar/); - lives_and { is( App->new_with_options->another_thingy, 'bar' ) } 'Underscore in option name'; + ok ! exception { is( App->new_with_options->another_thingy, 'bar' ) }, 'Underscore in option name'; } { local @ARGV = (qw/--another-thingy bar/); - throws_ok { App->new_with_options } qr/Unknown option: another-thingy/; + like exception { App->new_with_options }, qr/Unknown option: another-thingy/; } diff --git a/t/100_gld_default_bug.t b/t/100_gld_default_bug.t index a7dc478..3237cd9 100644 --- a/t/100_gld_default_bug.t +++ b/t/100_gld_default_bug.t @@ -4,7 +4,6 @@ use strict; use warnings; use Test::More tests => 5; -use Test::Exception; use Test::Requires { 'Getopt::Long::Descriptive' => 0.01, # skip all if not installed diff --git a/t/104_override_usage.t b/t/104_override_usage.t index d3d0868..887844b 100644 --- a/t/104_override_usage.t +++ b/t/104_override_usage.t @@ -1,7 +1,7 @@ use strict; use warnings; use Test::More 0.88; -use Test::Exception; +use Test::Fatal; { package MyScript; @@ -29,13 +29,13 @@ use Test::Exception; { local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception; local @ARGV = ('--help'); - throws_ok { MyScript->new_with_options } qr/A foo/; + like exception { MyScript->new_with_options }, qr/A foo/; is $MyScript::usage, 1; } { local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception; local @ARGV = ('-q'); # Does not exist - throws_ok { MyScript->new_with_options } qr/A foo/; + like exception { MyScript->new_with_options }, qr/A foo/; is_deeply \@MyScript::warnings, [ 'Unknown option: q ' diff --git a/t/107_no_auto_help.t b/t/107_no_auto_help.t index f7d615a..5ff7780 100644 --- a/t/107_no_auto_help.t +++ b/t/107_no_auto_help.t @@ -42,7 +42,7 @@ my $fail_on_exit = 1; } use Test::Warn 0.21; -use Test::Exception; +use Test::Fatal; END { ok(!$fail_on_exit, 'getoptions() lives'); @@ -57,7 +57,7 @@ END { @ARGV = ('--help'); warning_like { - throws_ok { Class->new_with_options } + like exception { Class->new_with_options }, #usage: 107_no_auto_help.t [-?] [long options...] qr/^usage: [\d\w]+\Q.t [-?] [long options...]\E.\s+\Q-? --usage --help Prints this usage information.\E.\s+--configfile/ms, 'usage information looks good'; diff --git a/t/109_help_flag.t b/t/109_help_flag.t index af21653..70a95ab 100644 --- a/t/109_help_flag.t +++ b/t/109_help_flag.t @@ -18,7 +18,7 @@ use strict; use warnings; use Test::More tests => 6; -use Test::Exception; +use Test::Fatal; { package MyClass; @@ -39,7 +39,7 @@ foreach my $args ( ['--help'], ['--usage'], ['--?'], ['-?'] ) { local @ARGV = @$args; - throws_ok { MyClass->new_with_options() } + like exception { MyClass->new_with_options() }, qr/^usage: (?:[\d\w]+)\Q.t [-?] [long options...]\E.^\t\Q-? --usage --help Prints this usage information.\E$/ms, 'Help request detected; usage information properly printed'; } diff --git a/t/110_sort_usage_by_attr_order.t b/t/110_sort_usage_by_attr_order.t index c12f4b6..bddaffa 100644 --- a/t/110_sort_usage_by_attr_order.t +++ b/t/110_sort_usage_by_attr_order.t @@ -10,7 +10,6 @@ use strict; use warnings; use Test::More tests => 1; -use Test::Exception; { package MyClass;