On Sunday 27 January 2002 09:31, Jarkko Hietaniemi wrote:
> Thanks, applied. Check to skip() that the message ends sanely?
Here's an approach with a test case that demonstrates the problem.
-- c
--- lib/Test/~Builder.pm Sun Jan 27 12:09:35 2002
+++ lib/Test/Builder.pm Sun Jan 27 12:15:52 2002
@@ -207,7 +207,7 @@
my $out = "1..0";
$out .= " # Skip $reason" if $reason;
- $out .= "\n";
+ $out .= "\n" unless $out =~ /\n\z/;
$Skip_All = 1;
@@ -275,7 +275,7 @@
$out .= " # TODO $what_todo";
}
- $out .= "\n";
+ $out .= "\n" unless $out =~ /\n\z/;
$self->_print($out);
@@ -573,7 +573,8 @@
my $out = "ok";
$out .= " $Curr_Test" if $self->use_numbers;
- $out .= " # skip $why\n";
+ $out .= " # skip $why";
+ $out .= "\n" unless $out =~ /\n\z/;
$Test->_print($out);
@@ -607,7 +608,8 @@
my $out = "not ok";
$out .= " $Curr_Test" if $self->use_numbers;
- $out .= " # TODO $why\n";
+ $out .= " # TODO $why";
+ $out .= "\n" unless $out =~ /\n\z/;
$Test->_print($out);
--- lib/Test/Simple/t/~output.t Sun Jan 27 11:54:29 2002
+++ lib/Test/Simple/t/output.t Sun Jan 27 12:17:59 2002
@@ -3,12 +3,12 @@
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
- @INC = '../lib';
+ @INC = ('../lib', '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.
@@ -23,6 +23,13 @@
$test_num++;
}
+BEGIN {
+ package Test::Builder;
+ use subs qw( exit );
+ package main;
+}
+
+use vars qw( $TODO );
use Test::Builder;
my $Test = Test::Builder->new();
@@ -55,3 +62,27 @@
ok($lines[1] =~ /Hello!/);
unlink('foo');
+
+use TieOut;
+local *FAKEOUT;
+$out = tie *FAKEOUT, 'TieOut';
+$Test->output(\*FAKEOUT);
+{
+ $TODO = '';
+
+ local *Test::Builder::exit;
+ *Test::Builder::exit = sub (;$) {};
+ $Test->exported_to('main');
+ $Test->no_ending(1);
+ $Test->no_plan();
+
+ # create output, add extraneous newlines
+ $Test->skip_all("skip all\n");
+ $Test->ok(1, "ok\n");
+ $Test->skip("skip\n");
+ $Test->todo_skip("todo skip\n");
+}
+
+# each test should have only one newline, so as not to confuse Test::Harness
+@lines = split(/\n/, $out->read());
+ok( @lines == 4, 'should suppress extra newlines in test names' );