diff options
author | Michael G. Schwern <schwern@pobox.com> | 2001-09-18 15:53:48 -0400 |
---|---|---|
committer | Abhijit Menon-Sen <ams@wiw.org> | 2001-09-19 01:23:55 +0000 |
commit | 0cd946aa8ca5f84826831f3a54bb81945edfa014 (patch) | |
tree | 94e11dea806b85281382e594c8e5c36b98608b97 /lib | |
parent | ea63ed0e75f87f41b120354ed354081869ee56fc (diff) | |
download | perl-0cd946aa8ca5f84826831f3a54bb81945edfa014.tar.gz |
[PATCH] Syncing with Test::Simple 0.19
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 <schwern@pobox.com>
Date: Tue, 18 Sep 2001 22:07:13 -0400
Message-Id: <20010918220713.B19616@blackrider>
p4raw-id: //depot/perl@12080
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Test/More.pm | 4 | ||||
-rw-r--r-- | lib/Test/Simple.pm | 16 | ||||
-rw-r--r-- | lib/Test/Simple/Changes | 10 | ||||
-rw-r--r-- | lib/Test/Simple/t/exit.t | 7 | ||||
-rw-r--r-- | lib/Test/Simple/t/extra.t | 1 | ||||
-rw-r--r-- | lib/Test/Simple/t/fail-more.t | 2 | ||||
-rw-r--r-- | lib/Test/Simple/t/fail.t | 1 | ||||
-rw-r--r-- | lib/Test/Simple/t/missing.t | 1 | ||||
-rw-r--r-- | lib/Test/Simple/t/todo.t | 18 | ||||
-rw-r--r-- | lib/Test/Tutorial.pod | 22 |
10 files changed, 61 insertions, 21 deletions
diff --git a/lib/Test/More.pm b/lib/Test/More.pm index 925e48edca..92d1d88ba3 100644 --- a/lib/Test/More.pm +++ b/lib/Test/More.pm @@ -14,7 +14,7 @@ BEGIN { 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 @@ USE my $ok = ok( !$@, "use $module;" ); unless( $ok ) { + chomp $@; my_print *TESTERR, <<DIAGNOSTIC; # Tried to use '$module'. # Error: $@ @@ -598,6 +599,7 @@ REQUIRE my $ok = ok( !$@, "require $module;" ); unless( $ok ) { + chomp $@; my_print *TESTERR, <<DIAGNOSTIC; # Tried to require '$module'. # Error: $@ diff --git a/lib/Test/Simple.pm b/lib/Test/Simple.pm index 56706cbbf4..dda36a128f 100644 --- a/lib/Test/Simple.pm +++ b/lib/Test/Simple.pm @@ -7,7 +7,7 @@ use Test::Utils; 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 @@ sub no_plan { $| = 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 @@ sub ok ($;$) { $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 @@ ERR } $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 @@ ERR 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; diff --git a/lib/Test/Simple/Changes b/lib/Test/Simple/Changes index 741c05c18e..fd9e3f628d 100644 --- a/lib/Test/Simple/Changes +++ b/lib/Test/Simple/Changes @@ -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 diff --git a/lib/Test/Simple/t/exit.t b/lib/Test/Simple/t/exit.t index 86954ab847..855533c175 100644 --- a/lib/Test/Simple/t/exit.t +++ b/lib/Test/Simple/t/exit.t @@ -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 @@ my %Tests = ( 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; diff --git a/lib/Test/Simple/t/extra.t b/lib/Test/Simple/t/extra.t index 9d548949e3..e01240abed 100644 --- a/lib/Test/Simple/t/extra.t +++ b/lib/Test/Simple/t/extra.t @@ -32,6 +32,7 @@ my($out, $err) = Test::Simple::Catch::caught(); Test::Simple->import(tests => 3); +#line 30 ok(1, 'Foo'); ok(0, 'Bar'); ok(1, 'Yar'); diff --git a/lib/Test/Simple/t/fail-more.t b/lib/Test/Simple/t/fail-more.t index 6a85e2cb53..c8b0b59793 100644 --- a/lib/Test/Simple/t/fail-more.t +++ b/lib/Test/Simple/t/fail-more.t @@ -95,11 +95,9 @@ ERR # 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 diff --git a/lib/Test/Simple/t/fail.t b/lib/Test/Simple/t/fail.t index c101a71fa0..d4be3f021e 100644 --- a/lib/Test/Simple/t/fail.t +++ b/lib/Test/Simple/t/fail.t @@ -34,6 +34,7 @@ my($out, $err) = Test::Simple::Catch::caught(); Test::Simple->import(tests => 5); +#line 32 ok( 1, 'passing' ); ok( 2, 'passing still' ); ok( 3, 'still passing' ); diff --git a/lib/Test/Simple/t/missing.t b/lib/Test/Simple/t/missing.t index 7e64d23ef9..21235a9ee8 100644 --- a/lib/Test/Simple/t/missing.t +++ b/lib/Test/Simple/t/missing.t @@ -33,6 +33,7 @@ my($out, $err) = Test::Simple::Catch::caught(); Test::Simple->import(tests => 5); +#line 30 ok(1, 'Foo'); ok(0, 'Bar'); diff --git a/lib/Test/Simple/t/todo.t b/lib/Test/Simple/t/todo.t index 399aa475be..70ef083a00 100644 --- a/lib/Test/Simple/t/todo.t +++ b/lib/Test/Simple/t/todo.t @@ -6,7 +6,7 @@ BEGIN { 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 @@ TODO: { } 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'); +} diff --git a/lib/Test/Tutorial.pod b/lib/Test/Tutorial.pod index 86735ff61c..38f1f70c56 100644 --- a/lib/Test/Tutorial.pod +++ b/lib/Test/Tutorial.pod @@ -4,16 +4,26 @@ Test::Tutorial - A tutorial about writing really basic tests =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! - *sob* +B<AHHHHHHH!!!! NOT TESTING! Anything but testing! +Beat me, whip me, send me to Detroit, but don't make +me write tests!> + +B<*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. |