On Wednesday 31 July 2002 12:39, Michael G Schwern wrote:

> > This patch captures messages sent through diag() and stores them in the
> > diagnostic array.  Now all of the information the tests generate is
> > available for later inspection.

> Dude, where's my patch?

Did I completely miss it?  Let's try this instead.

-- c
diff -ur Test-Simple-0.46~/lib/Test/Builder.pm Test-Simple-0.46/lib/Test/Builder.pm
--- Test-Simple-0.46~/lib/Test/Builder.pm	Sat Jul 20 17:16:02 2002
+++ Test-Simple-0.46/lib/Test/Builder.pm	Sat Jul 27 09:39:22 2002
@@ -296,7 +296,7 @@
     my $todo = $self->todo($pack);
 
     my $out;
-    my $result = {};
+    my $result = $Test_Results[$Curr_Test-1] ||= {};
 
     unless( $test ) {
         $out .= "not ";
@@ -329,7 +329,6 @@
         $result->{type}   = '';
     }
 
-    $Test_Results[$Curr_Test-1] = $result;
     $out .= "\n";
 
     $self->_print($out);
@@ -658,13 +657,8 @@
     lock($Curr_Test);
     $Curr_Test++;
 
-    $Test_Results[$Curr_Test-1] = {
-        'ok'      => 1,
-        actual_ok => 1,
-        name      => '',
-        type      => 'skip',
-        reason    => $why,
-    };
+    my $results = $Test_Results[$Curr_Test-1] ||= {};
+    @$results{qw( ok actual_ok name type reason )} = ( 1, 1, '', 'skip', $why );
 
     my $out = "ok";
     $out   .= " $Curr_Test" if $self->use_numbers;
@@ -700,13 +694,9 @@
     lock($Curr_Test);
     $Curr_Test++;
 
-    $Test_Results[$Curr_Test-1] = {
-        'ok'      => 1,
-        actual_ok => 0,
-        name      => '',
-        type      => 'todo_skip',
-        reason    => $why,
-    };
+    my $results = $Test_Results[$Curr_Test-1] ||= {};
+    @$results{qw( ok actual_ok name type reason )} =
+        ( 1, 0, '', 'todo_skip', $why );
 
     my $out = "not ok";
     $out   .= " $Curr_Test" if $self->use_numbers;
@@ -897,6 +887,10 @@
     my $fh = $self->todo ? $self->todo_output : $self->failure_output;
     local($\, $", $,) = (undef, ' ', '');
     print $fh @msgs;
+    my $prev_test = $Curr_Test - 1;
+    $prev_test = 0 if $prev_test < 0;
+    $Test_Results[ $prev_test ]{diag} ||= [];
+    push @{ $Test_Results[ $prev_test ]{diag} }, @msgs;
 
     return 0;
 }
@@ -1350,7 +1344,7 @@
 
 In perl 5.8.0 and later, Test::Builder is thread-safe.  The test
 number is shared amongst all threads.  This means if one thread sets
-the test number using current_test() they will all be effected.
+the test number using current_test() they will all be affected.
 
 =head1 EXAMPLES
 
diff -ur Test-Simple-0.46~/t/details.t Test-Simple-0.46/t/details.t
--- Test-Simple-0.46~/t/details.t	Sat Jul 20 17:08:36 2002
+++ Test-Simple-0.46/t/details.t	Sat Jul 27 08:45:45 2002
@@ -47,6 +47,7 @@
 
 TODO: {
     local $TODO = 'i need a todo';
+#line 50
     $Test->ok( 0, 'a test to todo!' );
 
     push @Expected_Details, { 'ok'       => 1,
@@ -54,6 +55,7 @@
                               name       => 'a test to todo!',
                               type       => 'todo',
                               reason     => 'i need a todo',
+							  diag       => [ "#     Failed (TODO) test ($0 at line 50)\n" ],
                             };
 
     $Test->todo_skip( 'i need both' );
@@ -76,15 +78,19 @@
                           reason    => '',
                         };
 
+
 $Test->current_test(6);
+
 print "ok 6 - current_test incremented\n";
 push @Expected_Details, { 'ok'      => 1,
                           actual_ok => undef,
                           name      => undef,
                           type      => 'unknown',
                           reason    => 'incrementing test number',
+						  diag      => [ '# Added', '# diagnostics', "\n" ],
                         };
 
+$Test->diag(qw( Added diagnostics ));
 my @details = $Test->details();
 $Test->is_num( scalar @details, 6,
     'details() should return a list of all test details');

Reply via email to