Fix author requires to not fatally error on a single command iohandle_response
Brendan Byrd [Thu, 19 Apr 2012 21:35:51 +0000 (17:35 -0400)]
Fix author test platform to actually run on MSWin32

Makefile.PL
t/aggregate.t
t/author/http-server.t

index e502713..88cda90 100644 (file)
@@ -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';
@@ -68,35 +85,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();
 }
 
index 543fe02..0696abb 100644 (file)
@@ -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,
 });
index 0edba01..2927f18 100644 (file)
@@ -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) = @_;