perl-test-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r165381 - /perl/Apache-Test/branches/test-more-unstable/lib/Apache/Test.pm
Date Sat, 30 Apr 2005 06:53:00 GMT
Author: stas
Date: Fri Apr 29 23:52:59 2005
New Revision: 165381

URL: http://svn.apache.org/viewcvs?rev=165381&view=rev
Log:
drop Test.pm support, require Test::More (a must if we want to support sub-tests 
run by several perl threads, which Test.pm fail to handle since it doesn't maintain 
a proper shared counter)

Modified:
    perl/Apache-Test/branches/test-more-unstable/lib/Apache/Test.pm

Modified: perl/Apache-Test/branches/test-more-unstable/lib/Apache/Test.pm
URL: http://svn.apache.org/viewcvs/perl/Apache-Test/branches/test-more-unstable/lib/Apache/Test.pm?rev=165381&r1=165380&r2=165381&view=diff
==============================================================================
--- perl/Apache-Test/branches/test-more-unstable/lib/Apache/Test.pm (original)
+++ perl/Apache-Test/branches/test-more-unstable/lib/Apache/Test.pm Fri Apr 29 23:52:59 2005
@@ -17,6 +17,10 @@
 use strict;
 use warnings FATAL => 'all';
 
+# must be run first, so that Test::Builder will be threads-aware
+BEGIN { use Config; require threads if $] >= 5.008 && $Config{useithreads}}
+use Test::Builder;
+
 use Exporter ();
 use Config;
 use Apache::TestConfig ();
@@ -56,12 +60,7 @@
 sub import {
     my $class = shift;
 
-    # once Test::More always Test::More until plan() is called
-    if (($_[0] and $_[0] =~ m/^-withtestmore/) || @testmore) {
-        # special hoops for Test::More support
-
-        $real_plan = eval { 
-
+        $real_plan = eval {
             require Test::More; 
 
             no warnings qw(numeric);
@@ -80,15 +79,6 @@
         # clean up arguments to export_to_level
         shift;
         @EXPORT = (@test_more_exports, @Test::More::EXPORT);
-    }
-    else {
-        # the default - Test.pm support
-
-        require Test;
-        Test->import(qw(ok skip));
-        @testmore = ();               # reset, just in case.
-        $real_plan = \&Test::plan;
-    }
 
     $class->export_to_level(1, undef, @_ ? @_ : @EXPORT);
 }
@@ -506,8 +496,13 @@
 
 package Apache::TestToString;
 
+use Config;
 sub TIEHANDLE {
     my $string = "";
+    if ($] >= 5.008 && $Config{useithreads} && $INC{'threads.pm'}) {
+        require threads::shared;
+        &threads::shared::share(\$string);
+    }
     bless \$string;
 }
 
@@ -530,6 +525,22 @@
     untie *STDOUT;
     $s;
 }
+
+package Apache::TestToStringRequest;
+
+sub new {
+    my($class, $r) = @_;
+    die '$r is required' unless $r;
+    Apache::TestToString->start;
+    return bless \$r, __PACKAGE__;
+}
+
+sub DESTROY {
+    my $self = shift;
+    $$self->print(Apache::TestToString->finish);
+}
+
+
 
 1;
 __END__



Mime
View raw message