You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-commits@perl.apache.org by st...@apache.org on 2005/04/30 08:53:00 UTC

svn commit: r165381 - /perl/Apache-Test/branches/test-more-unstable/lib/Apache/Test.pm

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__



Re: svn commit: r165381 - /perl/Apache-Test/branches/test-more-unstable/lib/Apache/Test.pm

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> But it didn't really change anythings, but enforce Test::More. Are you
> sure other tests where you use Test::More don't behave that way?

yes.  from trunk:

$ make test TEST_FILES=t/more/02testmore.t; echo $?
...
t/more/02testmore....request has failed (the response code was: 404)
...
make: *** [run_tests] Error 1
2

from test-more-unstable

$ make test TEST_FILES=t/more/02testmore.t; echo $?
...
t/more/02testmore....request has failed (the response code was: 404)
...
0

> 
> I've now committed it to the unstable branch, do you still see it that way?

the above test was with a fresh checkout.

--Geoff

Re: svn commit: r165381 - /perl/Apache-Test/branches/test-more-unstable/lib/Apache/Test.pm

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
> stas@apache.org wrote:
> 
>>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)
> 
> 
> just FYI but while this was in trunk I noticed that there was a problem -
> t/TEST would _not_ exit 1 if the tests failed, making
> 
>   $ make test && sudo make install
> 
> install even if 'make test' failed.  after I reverted the change things went
> back to normal, so I didn't look into it any deeper.

But it didn't really change anythings, but enforce Test::More. Are you 
sure other tests where you use Test::More don't behave that way?

I've now committed it to the unstable branch, do you still see it that way?


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: svn commit: r165381 - /perl/Apache-Test/branches/test-more-unstable/lib/Apache/Test.pm

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

stas@apache.org wrote:
> 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)

just FYI but while this was in trunk I noticed that there was a problem -
t/TEST would _not_ exit 1 if the tests failed, making

  $ make test && sudo make install

install even if 'make test' failed.  after I reverted the change things went
back to normal, so I didn't look into it any deeper.

HTH

--Geoff