Change 12080 by ams@ams-lustre on 2001/09/19 01:23:55
Subject: [PATCH] Syncing with Test::Simple 0.19
From: Michael G Schwern <[EMAIL PROTECTED]>
Date: Tue, 18 Sep 2001 19:53:48 -0400
Message-Id: <20010918195348.M585@blackrider>
Subject: [REPATCH] Re: [PATCH lib/Test/More.pm] Stray newline confusing t/TEST
From: Michael G Schwern <[EMAIL PROTECTED]>
Date: Tue, 18 Sep 2001 22:07:13 -0400
Message-Id: <20010918220713.B19616@blackrider>
Affected files ...
... //depot/perl/lib/Test/More.pm#5 edit
... //depot/perl/lib/Test/Simple.pm#4 edit
... //depot/perl/lib/Test/Simple/Changes#3 edit
... //depot/perl/lib/Test/Simple/t/exit.t#6 edit
... //depot/perl/lib/Test/Simple/t/extra.t#6 edit
... //depot/perl/lib/Test/Simple/t/fail-more.t#3 edit
... //depot/perl/lib/Test/Simple/t/fail.t#7 edit
... //depot/perl/lib/Test/Simple/t/missing.t#6 edit
... //depot/perl/lib/Test/Simple/t/todo.t#2 edit
... //depot/perl/lib/Test/Tutorial.pod#2 edit
Differences ...
==== //depot/perl/lib/Test/More.pm#5 (text) ====
Index: perl/lib/Test/More.pm
--- perl/lib/Test/More.pm.~1~ Tue Sep 18 19:30:05 2001
+++ perl/lib/Test/More.pm Tue Sep 18 19:30:05 2001
@@ -14,7 +14,7 @@
require Exporter;
use vars qw($VERSION @ISA @EXPORT $TODO);
-$VERSION = '0.18';
+$VERSION = '0.19';
@ISA = qw(Exporter);
@EXPORT = qw(ok use_ok require_ok
is isnt like
@@ -567,6 +567,7 @@
my $ok = ok( !$@, "use $module;" );
unless( $ok ) {
+ chomp $@;
my_print *TESTERR, <<DIAGNOSTIC;
# Tried to use '$module'.
# Error: $@
@@ -598,6 +599,7 @@
my $ok = ok( !$@, "require $module;" );
unless( $ok ) {
+ chomp $@;
my_print *TESTERR, <<DIAGNOSTIC;
# Tried to require '$module'.
# Error: $@
==== //depot/perl/lib/Test/Simple.pm#4 (text) ====
Index: perl/lib/Test/Simple.pm
--- perl/lib/Test/Simple.pm.~1~ Tue Sep 18 19:30:05 2001
+++ perl/lib/Test/Simple.pm Tue Sep 18 19:30:05 2001
@@ -7,7 +7,7 @@
use vars qw($VERSION);
-$VERSION = '0.18';
+$VERSION = '0.19';
my(@Test_Results) = ();
my($Num_Tests, $Planned_Tests, $Test_Died) = (0,0,0);
@@ -73,7 +73,7 @@
$| = 1;
open(*TESTOUT, ">&STDOUT") or _whoa(1, "Can't dup STDOUT!");
-open(*TESTERR, ">&STDERR") or _whoa(1, "Can't dup STDERR!");
+open(*TESTERR, ">&STDOUT") or _whoa(1, "Can't dup STDOUT!");
{
my $orig_fh = select TESTOUT;
$| = 1;
@@ -155,14 +155,15 @@
$Num_Tests++;
- my_print *TESTERR, <<ERR if defined $name and $name !~ /\D/;
+ my_print *TESTERR, <<ERR if defined $name and $name =~ /^[\d\s]+$/;
You named your test '$name'. You shouldn't use numbers for your test names.
Very confusing.
ERR
my($pack, $file, $line) = caller;
- if( $pack eq 'Test::More' ) { # special case for Test::More's calls
+ # temporary special case for Test::More & Parrot::Test's calls.
+ if( $pack eq 'Test::More' || $pack eq 'Parrot::Test' ) {
($pack, $file, $line) = caller(1);
}
@@ -179,7 +180,7 @@
}
$msg .= "ok $Num_Tests";
- if( @_ == 2 ) {
+ if( defined $name ) {
$name =~ s|#|\\#|g; # # in a name can confuse Test::Harness.
$msg .= " - $name";
}
@@ -192,8 +193,9 @@
my_print *TESTOUT, $msg;
#'#
- unless( $test or $is_todo ) {
- my_print *TESTERR, "# Failed test ($file at line $line)\n";
+ unless( $test ) {
+ my $msg = $is_todo ? "Failed (TODO)" : "Failed";
+ my_print *TESTERR, "# $msg test ($file at line $line)\n";
}
return $test ? 1 : 0;
==== //depot/perl/lib/Test/Simple/Changes#3 (text) ====
Index: perl/lib/Test/Simple/Changes
--- perl/lib/Test/Simple/Changes.~1~ Tue Sep 18 19:30:05 2001
+++ perl/lib/Test/Simple/Changes Tue Sep 18 19:30:05 2001
@@ -1,5 +1,15 @@
Revision history for Perl extension Test::Simple
+0.19 Tue Sep 18 17:48:32 EDT 2001
+ * Test::Simple and Test::More no longer print their diagnostics
+ to STDERR. It instead goes to STDOUT.
+ * TODO tests which fail now print full failure diagnostics.
+ - Minor bug in ok()'s test name diagnostics made it think a blank
+ name was a number.
+ - ok() less draconian about test names
+ - Added temporary special case for Parrot::Test
+ - Now requiring File::Spec for our tests.
+
0.18 Wed Sep 5 20:35:24 EDT 2001
* ***API CHANGE*** can_ok() only counts as one test
- can_ok() has better diagnostics
==== //depot/perl/lib/Test/Simple/t/exit.t#6 (text) ====
Index: perl/lib/Test/Simple/t/exit.t
--- perl/lib/Test/Simple/t/exit.t.~1~ Tue Sep 18 19:30:05 2001
+++ perl/lib/Test/Simple/t/exit.t Tue Sep 18 19:30:05 2001
@@ -1,12 +1,13 @@
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
- use File::Spec;
}
# Can't use Test.pm, that's a 5.005 thing.
package My::Test;
+use File::Spec;
+
my $test_num = 1;
# Utility testing functions.
sub ok ($;$) {
@@ -43,13 +44,11 @@
print "1..".keys(%Tests)."\n";
-my $lib = File::Spec->catdir('lib', 'Test', 'Simple', 'sample_tests');
-
+my $lib = File::Spec->catdir(qw(lib Test Simple sample_tests));
while( my($test_name, $exit_codes) = each %Tests ) {
my($exit_code) = $exit_codes->[$IsVMS ? 1 : 0];
my $file = File::Spec->catfile($lib, $test_name);
-
my $wait_stat = system(qq{$^X -"I../lib" -"I../t/lib" $file});
my $actual_exit = $wait_stat >> 8;
==== //depot/perl/lib/Test/Simple/t/extra.t#6 (text) ====
Index: perl/lib/Test/Simple/t/extra.t
--- perl/lib/Test/Simple/t/extra.t.~1~ Tue Sep 18 19:30:05 2001
+++ perl/lib/Test/Simple/t/extra.t Tue Sep 18 19:30:05 2001
@@ -32,6 +32,7 @@
Test::Simple->import(tests => 3);
+#line 30
ok(1, 'Foo');
ok(0, 'Bar');
ok(1, 'Yar');
==== //depot/perl/lib/Test/Simple/t/fail-more.t#3 (text) ====
Index: perl/lib/Test/Simple/t/fail-more.t
--- perl/lib/Test/Simple/t/fail-more.t.~1~ Tue Sep 18 19:30:05 2001
+++ perl/lib/Test/Simple/t/fail-more.t Tue Sep 18 19:30:05 2001
@@ -95,11 +95,9 @@
# Failed test \\($filename at line 43\\)
# Tried to use 'Hooble::mooble::yooble'.
# Error: Can't locate Hooble.* in \\\@INC .*
-
# Failed test \\($filename at line 44\\)
# Tried to require 'ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble'.
# Error: Can't locate ALL.* in \\\@INC .*
-
# Looks like you failed 10 tests of 10.
ERR
==== //depot/perl/lib/Test/Simple/t/fail.t#7 (text) ====
Index: perl/lib/Test/Simple/t/fail.t
--- perl/lib/Test/Simple/t/fail.t.~1~ Tue Sep 18 19:30:05 2001
+++ perl/lib/Test/Simple/t/fail.t Tue Sep 18 19:30:05 2001
@@ -34,6 +34,7 @@
Test::Simple->import(tests => 5);
+#line 32
ok( 1, 'passing' );
ok( 2, 'passing still' );
ok( 3, 'still passing' );
==== //depot/perl/lib/Test/Simple/t/missing.t#6 (text) ====
Index: perl/lib/Test/Simple/t/missing.t
--- perl/lib/Test/Simple/t/missing.t.~1~ Tue Sep 18 19:30:05 2001
+++ perl/lib/Test/Simple/t/missing.t Tue Sep 18 19:30:05 2001
@@ -33,6 +33,7 @@
Test::Simple->import(tests => 5);
+#line 30
ok(1, 'Foo');
ok(0, 'Bar');
==== //depot/perl/lib/Test/Simple/t/todo.t#2 (text) ====
Index: perl/lib/Test/Simple/t/todo.t
--- perl/lib/Test/Simple/t/todo.t.~1~ Tue Sep 18 19:30:05 2001
+++ perl/lib/Test/Simple/t/todo.t Tue Sep 18 19:30:05 2001
@@ -6,7 +6,7 @@
Test::More->import(skip_all => 'Need the new Test::Harness');
}
else {
- Test::More->import(tests => 5);
+ Test::More->import(tests => 13);
}
}
@@ -30,3 +30,19 @@
}
pass("This is still not todo");
+
+
+TODO: {
+ local $TODO = "testing that error messages don't leak out of todo";
+
+ ok( 'this' eq 'that', 'ok' );
+
+ like( 'this', '/that/', 'like' );
+ is( 'this', 'that', 'is' );
+ isnt( 'this', 'this', 'isnt' );
+
+ can_ok('Fooble', 'yarble');
+ isa_ok('Fooble', 'yarble');
+ use_ok('Fooble');
+ require_ok('Fooble');
+}
==== //depot/perl/lib/Test/Tutorial.pod#2 (text) ====
Index: perl/lib/Test/Tutorial.pod
--- perl/lib/Test/Tutorial.pod.~1~ Tue Sep 18 19:30:05 2001
+++ perl/lib/Test/Tutorial.pod Tue Sep 18 19:30:05 2001
@@ -4,16 +4,26 @@
=head1 DESCRIPTION
- AHHHHHHH!!!! NOT B<TESTING>! Anything but testing!
- Beat me, whip me, send me to I<Detroit>, but don't make
- me write tests!
+
+B<AHHHHHHH!!!! NOT TESTING! Anything but testing!
+Beat me, whip me, send me to Detroit, but don't make
+me write tests!>
+
+B<*sob*>
- *sob*
+B<Besides, I don't know how to write the damned things.>
- Besides, I don't know how to write the damned things.
Is this you? Is writing tests right up there with writing
-documentation and having your fingernails pulled out?
+documentation and having your fingernails pulled out? Did you open up
+a test and read
+
+ ######## We start with some black magic
+
+and decide that's quite enough for you?
+
+It's ok. That's all gone now. We've done all the black magic for
+you. And here are the tricks...
=head2 Nuts and bolts of testing.
End of Patch.