From: Karen Etheridge Date: Tue, 24 Aug 2010 21:15:55 +0000 (-0700) Subject: use Test::Requires in tests X-Git-Tag: 1.11~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4d438a84f437bcb3c43a04c27823b8b431cd3f55;p=gitmo%2FMoose.git use Test::Requires in tests --- diff --git a/Makefile.PL b/Makefile.PL index 51224e6..6c43c6f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -26,6 +26,7 @@ requires 'Try::Tiny' => '0.02'; test_requires 'Test::More' => '0.88'; test_requires 'Test::Exception' => '0.27'; +test_requires 'Test::Requires' => '0.05'; author_requires 'File::Find::Rule'; author_requires 'Module::Info'; diff --git a/t/020_attributes/027_accessor_override_method.t b/t/020_attributes/027_accessor_override_method.t index b20ed3c..d3c1a58 100644 --- a/t/020_attributes/027_accessor_override_method.t +++ b/t/020_attributes/027_accessor_override_method.t @@ -3,10 +3,9 @@ use strict; use warnings; use Test::More; -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; -} +use Test::Requires { + 'Test::Output' => '0.01', # skip all if not installed +}; { package Foo; diff --git a/t/020_attributes/034_bad_coerce.t b/t/020_attributes/034_bad_coerce.t index f520052..3d99f89 100644 --- a/t/020_attributes/034_bad_coerce.t +++ b/t/020_attributes/034_bad_coerce.t @@ -2,10 +2,10 @@ use strict; use warnings; use Test::More; -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; -} + +use Test::Requires { + 'Test::Output' => '0.01', # skip all if not installed +}; { package Foo; diff --git a/t/030_roles/019_build.t b/t/030_roles/019_build.t index 0efd76d..faa5cbc 100644 --- a/t/030_roles/019_build.t +++ b/t/030_roles/019_build.t @@ -2,10 +2,10 @@ use strict; use warnings; use Test::More; -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; -} + +use Test::Requires { + 'Test::Output' => '0.01', # skip all if not installed +}; # this test script ensures that my idiom of: # role: sub BUILD, after BUILD diff --git a/t/040_type_constraints/009_union_types_and_coercions.t b/t/040_type_constraints/009_union_types_and_coercions.t index 88be3b6..abedd6c 100644 --- a/t/040_type_constraints/009_union_types_and_coercions.t +++ b/t/040_type_constraints/009_union_types_and_coercions.t @@ -6,11 +6,10 @@ use warnings; use Test::More; use Test::Exception; -BEGIN { - eval "use IO::String; use IO::File;"; - plan skip_all => "IO::String and IO::File are required for this test" if $@; -} - +use Test::Requires { + 'IO::String' => '0.01', # skip all if not installed + 'IO::File' => '0.01', +}; { package Email::Moose; diff --git a/t/050_metaclasses/012_moose_exporter.t b/t/050_metaclasses/012_moose_exporter.t index d693b83..e37669d 100644 --- a/t/050_metaclasses/012_moose_exporter.t +++ b/t/050_metaclasses/012_moose_exporter.t @@ -5,11 +5,10 @@ use warnings; use Test::More; use Test::Exception; -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; -} +use Test::Requires { + 'Test::Output' => '0.01', # skip all if not installed +}; { package HasOwnImmutable; diff --git a/t/060_compat/001_module_refresh_compat.t b/t/060_compat/001_module_refresh_compat.t index e02a882..03553f9 100644 --- a/t/060_compat/001_module_refresh_compat.t +++ b/t/060_compat/001_module_refresh_compat.t @@ -11,10 +11,9 @@ use Test::Exception; use File::Spec; use File::Temp 'tempdir'; -BEGIN { - eval "use Module::Refresh;"; - plan skip_all => "Module::Refresh is required for this test" if $@; -} +use Test::Requires { + 'Module::Refresh' => '0.01', # skip all if not installed +}; =pod diff --git a/t/200_examples/002_example_Moose_POOP.t b/t/200_examples/002_example_Moose_POOP.t index 81b6e5d..9db4ee2 100644 --- a/t/200_examples/002_example_Moose_POOP.t +++ b/t/200_examples/002_example_Moose_POOP.t @@ -5,12 +5,10 @@ use warnings; use Test::More; -BEGIN { - eval "use DBM::Deep 1.0003;"; - plan skip_all => "DBM::Deep 1.0003 (or greater) is required for this test" if $@; - eval "use DateTime::Format::MySQL;"; - plan skip_all => "DateTime::Format::MySQL is required for this test" if $@; -} +use Test::Requires { + 'DBM::Deep' => '1.0003', # skip all if not installed + 'DateTime::Format::MySQL' => '0.01', +}; use Test::Exception; diff --git a/t/200_examples/004_example_w_DCS.t b/t/200_examples/004_example_w_DCS.t index f3eca37..671781c 100644 --- a/t/200_examples/004_example_w_DCS.t +++ b/t/200_examples/004_example_w_DCS.t @@ -14,10 +14,9 @@ Pretty well if I do say so myself :) =cut -BEGIN { - eval "use Declare::Constraints::Simple;"; - plan skip_all => "Declare::Constraints::Simple is required for this test" if $@; -} +use Test::Requires { + 'Declare::Constraints::Simple' => '0.01', # skip all if not installed +}; use Test::Exception; diff --git a/t/200_examples/005_example_w_TestDeep.t b/t/200_examples/005_example_w_TestDeep.t index 49030cc..676ae29 100644 --- a/t/200_examples/005_example_w_TestDeep.t +++ b/t/200_examples/005_example_w_TestDeep.t @@ -15,10 +15,9 @@ but it is not completely horrid either. =cut -BEGIN { - eval "use Test::Deep;"; - plan skip_all => "Test::Deep is required for this test" if $@; -} +use Test::Requires { + 'Test::Deep' => '0.01', # skip all if not installed +}; use Test::Exception; diff --git a/t/300_immutable/010_constructor_is_not_moose.t b/t/300_immutable/010_constructor_is_not_moose.t index 5ac676e..e30d673 100644 --- a/t/300_immutable/010_constructor_is_not_moose.t +++ b/t/300_immutable/010_constructor_is_not_moose.t @@ -4,10 +4,10 @@ use strict; use warnings; use Test::More; -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; -} + +use Test::Requires { + 'Test::Output' => '0.01', # skip all if not installed +}; { package NotMoose; diff --git a/t/300_immutable/011_constructor_is_wrapped.t b/t/300_immutable/011_constructor_is_wrapped.t index 6759134..e203db3 100644 --- a/t/300_immutable/011_constructor_is_wrapped.t +++ b/t/300_immutable/011_constructor_is_wrapped.t @@ -4,10 +4,10 @@ use strict; use warnings; use Test::More; -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; -} + +use Test::Requires { + 'Test::Output' => '0.01', # skip all if not installed +}; { package ModdedNew; diff --git a/t/300_immutable/013_immutable_roundtrip.t b/t/300_immutable/013_immutable_roundtrip.t index a9bc1c8..a77b223 100644 --- a/t/300_immutable/013_immutable_roundtrip.t +++ b/t/300_immutable/013_immutable_roundtrip.t @@ -4,10 +4,10 @@ use strict; use warnings; use Test::More; -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; -} + +use Test::Requires { + 'Test::Output' => '0.01', # skip all if not installed +}; { package Foo; diff --git a/xt/author/pod.t b/xt/author/pod.t index 4ae1af3..5627f22 100644 --- a/xt/author/pod.t +++ b/xt/author/pod.t @@ -5,7 +5,8 @@ use warnings; use Test::More; -eval "use Test::Pod 1.14"; -plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; +use Test::Requires { + 'Test::Pod' => '1.14', # skip all if not installed +}; all_pod_files_ok(); diff --git a/xt/author/pod_coverage.t b/xt/author/pod_coverage.t index acfdff6..cda0317 100644 --- a/xt/author/pod_coverage.t +++ b/xt/author/pod_coverage.t @@ -5,8 +5,9 @@ use warnings; use Test::More; -eval "use Test::Pod::Coverage 1.04"; -plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; +use Test::Requires { + 'Test::Pod::Coverage' => '1.04', # skip all if not installed +}; # This is a stripped down version of all_pod_coverage_ok which lets us # vary the trustme parameter per module. diff --git a/xt/author/tabs.t b/xt/author/tabs.t index 1b9c5b9..b794cee 100644 --- a/xt/author/tabs.t +++ b/xt/author/tabs.t @@ -5,8 +5,9 @@ use warnings; use Test::More; -eval "use Test::NoTabs 0.8"; -plan skip_all => "Test::NoTabs 0.8 required for testing tabs" if $@; +use Test::Requires { + 'Test::NoTabs' => '0.8', # skip all if not installed +}; # Module::Install has tabs, so we can't check 'inc' or ideally '.' all_perl_files_ok('lib', 't', 'xt'); diff --git a/xt/author/test-my-dependents.t b/xt/author/test-my-dependents.t index 814058c..a8ca16e 100644 --- a/xt/author/test-my-dependents.t +++ b/xt/author/test-my-dependents.t @@ -7,9 +7,10 @@ use Test::More; plan skip_all => 'This test will not run unless you set MOOSE_TEST_MD to a true value' unless $ENV{MOOSE_TEST_MD}; -eval 'use Test::DependentModules qw( test_all_dependents test_module );'; -plan skip_all => 'This test requires Test::DependentModules' - if $@; +use Test::Requires { + 'Test::DependentModules' => '0.01', # skip all if not installed +}; +use Test::DependentModules qw( test_all_dependents test_module ); $ENV{PERL_TEST_DM_LOG_DIR} = abs_path('.');