From: Brendan Byrd Date: Thu, 19 Apr 2012 21:35:51 +0000 (-0400) Subject: Fix author requires to not fatally error on a single command Fix author test platform... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=refs%2Fheads%2Fno_base_component_view Fix author requires to not fatally error on a single command Fix author test platform to actually run on MSWin32 --- diff --git a/Makefile.PL b/Makefile.PL index 39a964e..e13cef0 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,14 +1,31 @@ use strict; use warnings; -use inc::Module::Install 0.91; +use inc::Module::Install 1.06; # Ensure that these get used - yes, M::I loads them for us, but if you're # in author mode and don't have them installed, then the error is tres # cryptic. -use Module::Install::AuthorRequires; use Module::Install::CheckConflicts; -use Module::Install::AuthorTests; use Module::Install::Authority; +# (Stolen from DBIC) +# nasty hook into both M::AI init and the prompter, so that the optdep message +# comes at the right places (on top and then right above the prompt) +my $optdep_msg = ''; +{ + require Module::AutoInstall; + no warnings 'redefine'; + no strict 'refs'; + + for (qw/_prompt import/) { + my $meth = "Module::AutoInstall::$_"; + my $orig = \&{$meth}; + *{$meth} = sub { + print $optdep_msg; + goto $orig; + }; + } +} + perl_version '5.008003'; name 'Catalyst-Runtime'; @@ -67,35 +84,71 @@ test_requires 'Test::More' => '0.88'; test_requires 'Data::Dump'; test_requires 'HTTP::Request::Common'; -# aggregate tests if AGGREGATE_TESTS is set and a recent Test::Aggregate and a Test::Simple it works with is available -if ($ENV{AGGREGATE_TESTS} && can_use('Test::Simple', '0.88') && can_use('Test::Aggregate', '0.364')) { - author_requires('Test::Aggregate', '0.364'); - author_requires('Test::Simple', '0.88'); - open my $fh, '>', '.aggregating'; -} -else { - unlink '.aggregating'; - tests 't/*.t t/aggregate/*.t'; -} - -author_requires 'CatalystX::LeakChecker', '0.05'; -author_requires 'File::Copy::Recursive'; # For http server test -author_requires 'Catalyst::Devel', '1.0'; # For http server test -author_requires 'Catalyst::Engine::PSGI'; -author_requires 'Test::Without::Module'; -author_requires 'Starman'; -author_requires 'MooseX::Daemonize'; - -author_tests 't/author'; -author_requires(map {; $_ => 0 } qw( - Test::NoTabs - Test::Pod - Test::Pod::Coverage - Test::Spelling - Pod::Coverage::TrustPod -)); - +# No fatal author_* BS! This is the sole AUTHOR block if ($Module::Install::AUTHOR) { + $optdep_msg .= <<'EOW'; + +****************************************************************************** +****************************************************************************** +*** *** +*** AUTHOR MODE: all optional test dependencies converted to hard requires *** +*** *** +****************************************************************************** +****************************************************************************** + +EOW + # This is now default to on unless it is explicitly set to zero + #my $aggregate_tests = exists $ENV{AGGREGATE_TESTS} ? $ENV{AGGREGATE_TESTS} : 1; + + #### This is NOT default until Test::Aggregate fixes their Test::Builder monkey patching! + #### Remove this code and uncomment the above when it's fixed! + my $aggregate_tests = $ENV{AGGREGATE_TESTS}; + + # aggregate tests if AGGREGATE_TESTS is set and a recent Test::Aggregate and a Test::Simple it works with is available + if ($aggregate_tests && can_use('Test::Simple', '0.88') && can_use('Test::Aggregate', '0.364')) { + test_requires('Test::Aggregate', '0.364'); + test_requires('Test::Simple', '0.88'); + open my $fh, '>', '.aggregating'; + } + else { + if ($aggregate_tests) { + # Friendly Reminder... + # There's no such thing as test_recommends (which wouldn't even end + # up on the module list, anyway), so we just print. + $optdep_msg .= <<'EOW'; +****************************************************************************** +* Author-level aggregate testing can go a lot smoother with Test::Aggregate * +* and Test::Simple installed. Resorting to old-style multi-processed tests. * +* * +* (This notice can be silenced by explicitly setting AGGREGATE_TESTS=0.) * +****************************************************************************** +EOW + #recommends('Test::Aggregate', '0.364'); + #recommends('Test::Simple', '0.88'); + } + unlink '.aggregating'; + tests 't/*.t t/aggregate/*.t'; + } + + test_requires 'CatalystX::LeakChecker', '0.05'; + test_requires 'File::Copy::Recursive'; # For http server test + test_requires 'Catalyst::Devel', '1.0'; # For http server test + test_requires 'Catalyst::Engine::PSGI'; + test_requires 'Test::Without::Module'; + unless ($^O eq 'MSWin32') { + test_requires 'Starman'; + test_requires 'MooseX::Daemonize'; + } + + tests ('t/*.t t/author/*.t'); + test_requires(map {; $_ => 0 } qw( + Test::NoTabs + Test::Pod + Test::Pod::Coverage + Test::Spelling + Pod::Coverage::TrustPod + )); + darwin_check_no_resource_forks(); } diff --git a/t/aggregate.t b/t/aggregate.t index 543fe02..0696abb 100644 --- a/t/aggregate.t +++ b/t/aggregate.t @@ -23,7 +23,7 @@ BEGIN { my $tests = Test::Aggregate->new({ (@ARGV ? (tests => \@ARGV) : (dirs => 't/aggregate')), - verbose => 0, + verbose => 1, # failures only set_filenames => 1, findbin => 1, }); diff --git a/t/author/http-server.t b/t/author/http-server.t index 0edba01..2927f18 100644 --- a/t/author/http-server.t +++ b/t/author/http-server.t @@ -77,6 +77,15 @@ rmtree "$FindBin::Bin/../../t/tmp" if -d "$FindBin::Bin/../../t/tmp"; is( $return, 0, 'live tests' ); +# kill 'INT' doesn't exist in Windows, so to prevent child hanging, +# this process will need to commit seppuku to clean up the children. +if ($^O eq 'MSWin32') { + # Furthermore, it needs to do it 'politely' so that TAP doesn't + # smell anything 'dubious'. + require Win32::Process; # core in all versions of Win32 Perl + Win32::Process::KillProcess($$, $return); +} + sub wait_port_timeout { my ($port, $timeout) = @_;