From: Peter Rabbitson Date: Sun, 26 Sep 2010 16:39:21 +0000 (+0200) Subject: Reorganize runmode detection a bit X-Git-Tag: v0.08124~65 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=39c9c72df61c84b595715e3d164bacc0b8e68439;p=dbsrgits%2FDBIx-Class.git Reorganize runmode detection a bit Add two helpers: is_smoker and is_plain, to make it easier to indicate which test should run when. Note that cpanm sets AUTOMATED_TESTING to trick modules that expect input, so is_smoker isn't as simple as it should have been. --- diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index 7ce9410..953b249 100644 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -3,7 +3,7 @@ package # hide from PAUSE use strict; use warnings; -use DBICTest::AuthorCheck; +use DBICTest::RunMode; use DBICTest::Schema; use Carp; diff --git a/t/lib/DBICTest/AuthorCheck.pm b/t/lib/DBICTest/RunMode.pm similarity index 92% rename from t/lib/DBICTest/AuthorCheck.pm rename to t/lib/DBICTest/RunMode.pm index c75b887..6da3ead 100644 --- a/t/lib/DBICTest/AuthorCheck.pm +++ b/t/lib/DBICTest/RunMode.pm @@ -1,5 +1,5 @@ package # hide from PAUSE - DBICTest::AuthorCheck; + DBICTest::RunMode; use strict; use warnings; @@ -108,10 +108,18 @@ sub is_author { return ( ( not -d $root->subdir ('inc') ) or - ( -e $root->subdir ('inc')->file ($^O eq 'VMS' ? '_author' : '.author') ) + ( -e $root->subdir ('inc')->subdir ($^O eq 'VMS' ? '_author' : '.author') ) ); } +sub is_smoker { + return ( $ENV{AUTOMATED_TESTING} && ! $ENV{PERL5_CPANM_IS_RUNNING} && ! $ENV{RELEASE_TESTING} ) +} + +sub is_plain { + return (! __PACKAGE__->is_smoker && ! __PACKAGE__->is_author && ! $ENV{RELEASE_TESTING} ) +} + # Try to determine the root of a checkout/untar if possible # or return undef sub _find_co_root { diff --git a/t/zzzzzzz_perl_perf_bug.t b/t/zzzzzzz_perl_perf_bug.t index 558b4f0..e0aad96 100644 --- a/t/zzzzzzz_perl_perf_bug.t +++ b/t/zzzzzzz_perl_perf_bug.t @@ -23,8 +23,8 @@ plan skip_all => 'Skipping RH perl performance bug tests as DBIC_NO_WARN_BAD_PERL set' if ( $ENV{DBIC_NO_WARN_BAD_PERL} ); -plan skip_all => 'Skipping as AUTOMATED_TESTING is set' - if ( $ENV{AUTOMATED_TESTING} ); +plan skip_all => 'Skipping as system appears to be a smoker' + if DBICTest::RunMode->is_smoker; plan tests => 3; diff --git a/t/zzzzzzz_sqlite_deadlock.t b/t/zzzzzzz_sqlite_deadlock.t index a049f22..c967c25 100644 --- a/t/zzzzzzz_sqlite_deadlock.t +++ b/t/zzzzzzz_sqlite_deadlock.t @@ -9,12 +9,12 @@ use File::Temp (); use DBICTest; use DBICTest::Schema; -unless ( DBICTest::AuthorCheck->is_author || $ENV{AUTOMATED_TESTING} || $ENV{RELEASE_TESTING} ) { +if ( DBICTest::RunMode->is_plain ) { plan( skip_all => "Skipping test on plain module install" ); } plan tests => 2; -my $wait_for = 30; # how many seconds to wait +my $wait_for = 120; # how many seconds to wait for my $close (0,1) { diff --git a/xt/eol.t b/xt/eol.t index 609f6ad..e61ce41 100644 --- a/xt/eol.t +++ b/xt/eol.t @@ -6,7 +6,7 @@ use lib 't/lib'; use DBICTest; # Don't run tests for installs -unless ( DBICTest::AuthorCheck->is_author || $ENV{AUTOMATED_TESTING} || $ENV{RELEASE_TESTING} ) { +if ( DBICTest::RunMode->is_plain ) { plan( skip_all => "Author tests not required for installation" ); } @@ -15,7 +15,7 @@ plan skip_all => 'Test::EOL very broken'; require DBIx::Class; unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_eol') ) { my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_eol'); - $ENV{RELEASE_TESTING} || DBICTest::AuthorCheck->is_author + (! DBICTest::RunMode->is_plain && ! DBICTest::RunMode->is_smoker ) ? die ("Failed to load release-testing module requirements: $missing") : plan skip_all => "Test needs: $missing" } @@ -24,7 +24,7 @@ TODO: { local $TODO = 'Do not fix those yet - we have way too many branches out there, merging will be hell'; Test::EOL::all_perl_files_ok({ trailing_whitespace => 1}, qw/t xt lib script/, - DBICTest::AuthorCheck->is_author ? ('maint') : (), + DBICTest::RunMode->is_author ? ('maint') : (), ); } diff --git a/xt/notabs.t b/xt/notabs.t index de1baab..76895b2 100644 --- a/xt/notabs.t +++ b/xt/notabs.t @@ -6,21 +6,21 @@ use lib 't/lib'; use DBICTest; # Don't run tests for installs -unless ( DBICTest::AuthorCheck->is_author || $ENV{AUTOMATED_TESTING} || $ENV{RELEASE_TESTING} ) { +if ( DBICTest::RunMode->is_plain ) { plan( skip_all => "Author tests not required for installation" ); } require DBIx::Class; unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_notabs') ) { my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_notabs'); - $ENV{RELEASE_TESTING} || DBICTest::AuthorCheck->is_author + (! DBICTest::RunMode->is_plain && ! DBICTest::RunMode->is_smoker ) ? die ("Failed to load release-testing module requirements: $missing") : plan skip_all => "Test needs: $missing" } Test::NoTabs::all_perl_files_ok( qw/t xt lib script/, - DBICTest::AuthorCheck->is_author ? ('maint') : (), + DBICTest::RunMode->is_author ? ('maint') : (), ); # FIXME - need to fix Test::NoTabs - doesn't work with done_testing diff --git a/xt/pod.t b/xt/pod.t index 1c55c96..328a1ed 100644 --- a/xt/pod.t +++ b/xt/pod.t @@ -6,14 +6,14 @@ use lib qw(t/lib); use DBICTest; # Don't run tests for installs -unless ( DBICTest::AuthorCheck->is_author || $ENV{AUTOMATED_TESTING} || $ENV{RELEASE_TESTING} ) { +if ( DBICTest::RunMode->is_plain ) { plan( skip_all => "Author tests not required for installation" ); } require DBIx::Class; unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_pod') ) { my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_pod'); - $ENV{RELEASE_TESTING} || DBICTest::AuthorCheck->is_author + (! DBICTest::RunMode->is_plain && ! DBICTest::RunMode->is_smoker ) ? die ("Failed to load release-testing module requirements: $missing") : plan skip_all => "Test needs: $missing" } diff --git a/xt/podcoverage.t b/xt/podcoverage.t index 7f45665..8c9132e 100644 --- a/xt/podcoverage.t +++ b/xt/podcoverage.t @@ -8,7 +8,7 @@ use DBICTest; use namespace::clean; # Don't run tests for installs -unless ( DBICTest::AuthorCheck->is_author || $ENV{AUTOMATED_TESTING} || $ENV{RELEASE_TESTING} ) { +if ( DBICTest::RunMode->is_plain ) { plan( skip_all => "Author tests not required for installation" ); }