Aggregate http-server.t tests
Florian Ragwitz [Sat, 4 Dec 2010 21:19:37 +0000 (21:19 +0000)]
With this, I get to run the full suite in under 2 minutes again, as opposed to
the >3 minutes it took before.

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

index fc26f97..8dbd962 100644 (file)
@@ -57,11 +57,13 @@ test_requires 'Test::Exception';
 test_requires 'Test::More' => '0.88';
 
 # 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.35_05')) {
-    author_requires('Test::Aggregate', '0.35_05');
+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 join q{ },
         grep { $_ ne 't/aggregate.t' }
         map  { glob } qw[t/*.t t/aggregate/*.t];
index 660c5fe..6722046 100644 (file)
@@ -7,9 +7,9 @@ use FindBin;
 use lib "$FindBin::Bin/lib";
 
 BEGIN {
-    unless (eval { require Test::Aggregate; Test::Aggregate->VERSION('0.35_05'); 1 }) {
+    unless (eval { require Test::Aggregate; Test::Aggregate->VERSION('0.364'); 1 }) {
         require Test::More;
-        Test::More::plan(skip_all => 'Test::Aggregate 0.35_05 required for test aggregation');
+        Test::More::plan(skip_all => 'Test::Aggregate 0.364 required for test aggregation');
     }
 }
 
index 13a548b..5bab59b 100644 (file)
@@ -49,12 +49,14 @@ while ( check_port( 'localhost', $port ) != 1 ) {
 # run the testsuite against the HTTP server
 $ENV{CATALYST_SERVER} = "http://localhost:$port";
 
+chdir '..';
+
 my $return;
 if ( $single_test ) {
-    $return = system( "$^X -I../lib/ $single_test" );
+    $return = system( "$^X -Ilib/ $single_test" );
 }
 else {
-    $return = prove( ['../lib/'], [glob('../t/aggregate/live_*.t')] );
+    $return = prove( ['lib/'], [grep { $_ ne '..' } glob('t/aggregate/live_*.t')] );
 }
 
 # shut it down
@@ -89,8 +91,15 @@ sub prove {
         unshift @INC, @{ $inc };
 
         require TAP::Harness;
-        my $harness = TAP::Harness->new;
-        my $aggregator = $harness->runtests(@{ $tests });
+
+        my $aggr = -e '.aggregating';
+        my $harness = TAP::Harness->new({
+            ($aggr ? (test_args => $tests) : ())
+        });
+
+        my $aggregator = $aggr
+            ? $harness->runtests('t/aggregate.t')
+            : $harness->runtests(@{ $tests });
 
         exit $aggregator->has_errors ? 1 : 0;
     } else {