On Sat, Apr 13, 2002 at 04:18:24PM -0700, chromatic wrote:
> I'm not dead or pining for the fjords.
> 
> This was discussed at the end of January on p5p, and Benjamin Goldberg
> suggested the regexp solution that appears here.

For future reference, TieOut.pm is sitting in t/lib/

Here's what I've applied.

--- lib/Test/Builder.pm 12 Apr 2002 03:00:27 -0000      1.18
+++ lib/Test/Builder.pm 23 Apr 2002 02:16:28 -0000
@@ -850,6 +850,15 @@
 
     local($\, $", $,) = (undef, ' ', '');
     my $fh = $self->output;
+
+    # Escape each line after the first with a # so we don't
+    # confuse Test::Harness.
+    foreach (@msgs) {
+        s/\n(.)/\n# $1/sg;
+    }
+
+    push @msgs, "\n" unless $msgs[-1] =~ /\n\Z/;
+
     print $fh @msgs;
 }
 
--- t/output.t  11 Jan 2002 00:59:07 -0000      1.3
+++ t/output.t  23 Apr 2002 02:18:05 -0000
@@ -3,12 +3,15 @@
 BEGIN {
     if( $ENV{PERL_CORE} ) {
         chdir 't';
-        @INC = '../lib';
+        @INC = ('../lib', 'lib');
+    }
+    else {
+        unshift @INC, 't/lib';
     }
 }
 
 # Can't use Test.pm, that's a 5.005 thing.
-print "1..3\n";
+print "1..4\n";
 
 my $test_num = 1;
 # Utility testing functions.
@@ -21,8 +24,11 @@
     $ok .= "\n";
     print $ok;
     $test_num++;
+
+    return $test;
 }
 
+use TieOut;
 use Test::Builder;
 my $Test = Test::Builder->new();
 
@@ -55,3 +61,31 @@
 ok($lines[1] =~ /Hello!/);
 
 unlink('foo');
+
+
+# Ensure stray newline in name escaping works.
+$out = tie *FAKEOUT, 'TieOut';
+$Test->output(\*FAKEOUT);
+$Test->no_ending(1);
+$Test->plan(tests => 5);
+
+$Test->ok(1, "ok");
+$Test->ok(1, "ok\n");
+$Test->ok(1, "ok, like\nok");
+$Test->skip("wibble\nmoof");
+$Test->todo_skip("todo\nskip\n");
+
+my $output = $out->read;
+ok( $output eq <<OUTPUT ) || print STDERR $output;
+1..5
+ok 1 - ok
+ok 2 - ok
+# 
+ok 3 - ok, like
+# ok
+ok 4 # skip wibble
+# moof
+not ok 5 # TODO & SKIP todo
+# skip
+# 
+OUTPUT



-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
Woah, like, did anybody see my watch?

Reply via email to