perl-test-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r165216 - /perl/Apache-Test/trunk/lib/Apache/Test.pm
Date Thu, 28 Apr 2005 22:28:28 GMT
Author: stas
Date: Thu Apr 28 15:28:27 2005
New Revision: 165216

URL: http://svn.apache.org/viewcvs?rev=165216&view=rev
Log:
better threads support: 
- must boot threads before loading Test::More (otherwise it won't share the 
counter)
- various tweaks to allow threads to use the test framework when $r is invalid 
after cloning

Modified:
    perl/Apache-Test/trunk/lib/Apache/Test.pm

Modified: perl/Apache-Test/trunk/lib/Apache/Test.pm
URL: http://svn.apache.org/viewcvs/perl/Apache-Test/trunk/lib/Apache/Test.pm?rev=165216&r1=165215&r2=165216&view=diff
==============================================================================
--- perl/Apache-Test/trunk/lib/Apache/Test.pm (original)
+++ perl/Apache-Test/trunk/lib/Apache/Test.pm Thu Apr 28 15:28:27 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,10 +60,7 @@
 sub import {
     my $class = shift;
 
-# XXX: we need to bundle Test::More in the distro
-
         $real_plan = eval {
-
             require Test::More; 
 
             no warnings qw(numeric);
@@ -495,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;
 }
 
@@ -519,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