summaryrefslogtreecommitdiff
path: root/lib/Test
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2002-06-15 23:49:27 -0400
committerAbhijit Menon-Sen <ams@wiw.org>2002-06-16 09:00:51 +0000
commitd5d4ec93a4679c6ba299b53290a0903a25094cec (patch)
treef614812a6656569c4e54761ad97d67769cdfad04 /lib/Test
parent90fcb90269601d48315e5be1fd5ddd0619d05f27 (diff)
downloadperl-d5d4ec93a4679c6ba299b53290a0903a25094cec.tar.gz
Subject: [PATCH] Sync MakeMaker 6.01 -> 6.02
Date: Sun, 16 Jun 2002 03:49:27 -0400 Message-Id: <20020616074927.GD7403@ool-18b93024.dyn.optonline.net> Subject: [PATCH] Test::Harness 2.24 -> 2.25 From: Michael G Schwern <schwern@pobox.com> Date: Sun, 16 Jun 2002 03:58:40 -0400 Message-Id: <20020616075840.GE7403@ool-18b93024.dyn.optonline.net> p4raw-id: //depot/perl@17256
Diffstat (limited to 'lib/Test')
-rw-r--r--lib/Test/Harness.pm13
-rw-r--r--lib/Test/Harness/Changes12
-rw-r--r--lib/Test/Harness/Straps.pm19
-rw-r--r--lib/Test/Harness/t/callback.t17
-rw-r--r--lib/Test/Harness/t/strap-analyze.t48
-rw-r--r--lib/Test/Harness/t/test-harness.t42
6 files changed, 82 insertions, 69 deletions
diff --git a/lib/Test/Harness.pm b/lib/Test/Harness.pm
index 4714f77ecf..d79a6cb73d 100644
--- a/lib/Test/Harness.pm
+++ b/lib/Test/Harness.pm
@@ -1,5 +1,5 @@
# -*- Mode: cperl; cperl-indent-level: 4 -*-
-# $Id: Harness.pm,v 1.33 2002/05/29 23:02:48 schwern Exp $
+# $Id: Harness.pm,v 1.37 2002/06/16 06:55:09 schwern Exp $
package Test::Harness;
@@ -12,7 +12,7 @@ use Config;
use strict;
use vars qw($VERSION $Verbose $Switches $Have_Devel_Corestack $Curtest
- $Columns $verbose $switches $ML
+ $Columns $verbose $switches $ML $Strap
@ISA @EXPORT @EXPORT_OK
);
@@ -22,7 +22,7 @@ use vars qw($VERSION $Verbose $Switches $Have_Devel_Corestack $Curtest
$Have_Devel_Corestack = 0;
-$VERSION = '2.24';
+$VERSION = '2.25';
$ENV{HARNESS_ACTIVE} = 1;
@@ -36,7 +36,7 @@ my $Ignore_Exitcode = $ENV{HARNESS_IGNORE_EXITCODE};
my $Files_In_Dir = $ENV{HARNESS_FILELEAK_IN_DIR};
-my $Strap = Test::Harness::Straps->new;
+$Strap = Test::Harness::Straps->new;
@ISA = ('Exporter');
@EXPORT = qw(&runtests);
@@ -324,7 +324,8 @@ or failed based on their output to STDOUT (details above). It prints
out each individual test which failed along with a summary report and
a how long it all took.
-It returns true if everything was ok, false otherwise.
+It returns true if everything was ok. Otherwise it will die() with
+one of the messages in the DIAGNOSTICS section.
=for _private
This is just _run_all_tests() plus _show_results()
@@ -496,7 +497,7 @@ sub _run_all_tests {
print "$test{ml}ok\n ".join(', ', @msg)."\n";
} elsif ($test{max}) {
print "$test{ml}ok\n";
- } elsif (length $test{skip_all}) {
+ } elsif (defined $test{skip_all} and length $test{skip_all}) {
print "skipped\n all skipped: $test{skip_all}\n";
$tot{skipped}++;
} else {
diff --git a/lib/Test/Harness/Changes b/lib/Test/Harness/Changes
index 03eaab3563..53862ffae9 100644
--- a/lib/Test/Harness/Changes
+++ b/lib/Test/Harness/Changes
@@ -1,5 +1,17 @@
Revision history for Perl extension Test::Harness
+2.25 Sun Jun 16 03:00:33 EDT 2002
+ - $Strap is now a global to allow Test::Harness::Straps
+ experimentation.
+ - Little spelling nit in a diagnostic.
+ - Chris Richmond noted that the runtests() docs were wrong. It will
+ die, not return false, when any tests fail. This is silly, but
+ historically necessary for 'make test'. Docs corrected.
+ - MacPerl test fixes from Pudge. (mutation of bleadperl@16989)
+ - Undef warning introduced in 2.24 on skipped tests with no reasons
+ fixed.
+ * Test::Harness now depends on File::Spec
+
2.24 Wed May 29 19:02:18 EDT 2002
* Nikola Knezevic found a bug when tests are completely skipped
but no reason is given it was considered a failure.
diff --git a/lib/Test/Harness/Straps.pm b/lib/Test/Harness/Straps.pm
index 7b018aebd4..8f3d1168ef 100644
--- a/lib/Test/Harness/Straps.pm
+++ b/lib/Test/Harness/Straps.pm
@@ -1,12 +1,12 @@
# -*- Mode: cperl; cperl-indent-level: 4 -*-
-# $Id: Straps.pm,v 1.8 2002/05/29 23:02:48 schwern Exp $
+# $Id: Straps.pm,v 1.11 2002/06/16 06:55:10 schwern Exp $
package Test::Harness::Straps;
use strict;
use vars qw($VERSION);
use Config;
-$VERSION = '0.12';
+$VERSION = '0.13';
use Test::Harness::Assert;
use Test::Harness::Iterator;
@@ -187,7 +187,7 @@ sub _analyze_line {
# print "ok $num\n";
if( $self->{saw_lone_not} &&
($self->{lone_not_line} == $self->{line} - 1) )
- {
+ {
$result{ok} = 0;
}
@@ -207,7 +207,7 @@ sub _analyze_line {
$totals->{ok}++ if $pass;
if( $result{number} > 100000 ) {
- warn "Enourmous test number seen [test $result{number}]\n";
+ warn "Enormous test number seen [test $result{number}]\n";
warn "Can't detailize, too big.\n";
}
else {
@@ -328,11 +328,8 @@ sub _switches {
# When taint mode is on, PERL5LIB is ignored. So we need to put
# all that on the command line as -Is.
- if ($first =~ /^#!.*\bperl.*\s-\w*([Tt]+)/) {
- $s .= join " ", qq[ "-$1"], map {qq["-I$_"]} $self->_filtered_INC;
- } elsif ($^O eq 'MacOS') {
- $s .= join " ", map {qq["-I$_"]} $self->_filtered_INC;
- }
+ $s .= join " ", qq[ "-$1"], map {qq["-I$_"]} $self->_filtered_INC
+ if $first =~ /^#!.*\bperl.*\s-\w*([Tt]+)/;
close(TEST) or print "can't close $file. $!\n";
@@ -355,7 +352,7 @@ sub _INC2PERL5LIB {
$self->{_old5lib} = $ENV{PERL5LIB};
return join $Config{path_sep}, $self->_filtered_INC;
-}
+}
=item B<_filtered_INC>
@@ -399,7 +396,7 @@ sub _restore_PERL5LIB {
$ENV{PERL5LIB} = $self->{_old5lib};
}
}
-
+
=end _private
diff --git a/lib/Test/Harness/t/callback.t b/lib/Test/Harness/t/callback.t
index 74b2fe9e2e..d77495887c 100644
--- a/lib/Test/Harness/t/callback.t
+++ b/lib/Test/Harness/t/callback.t
@@ -10,13 +10,13 @@ BEGIN {
}
}
-use File::Spec::Functions;
+use Test::More;
+use File::Spec;
+my $Curdir = File::Spec->curdir;
my $SAMPLE_TESTS = $ENV{PERL_CORE}
- ? catdir(curdir(), 'lib', 'sample-tests')
- : catdir(curdir(), 't', 'sample-tests');
-
-use Test::More;
+ ? File::Spec->catdir($Curdir, 'lib', 'sample-tests')
+ : File::Spec->catdir($Curdir, 't', 'sample-tests');
%samples = (
bailout => [qw( header test test test bailout )],
@@ -51,15 +51,10 @@ $strap->{callback} = sub {
my($self, $line, $type, $totals) = @_;
push @out, $type;
};
-
-$SAMPLE_TESTS = VMS::Filespec::unixify($SAMPLE_TESTS) if $^O eq 'VMS';
while( my($test, $expect) = each %samples ) {
local @out = ();
-
- $strap->analyze_file($^O eq 'MacOS' ?
- catfile($SAMPLE_TESTS, $test) :
- "$SAMPLE_TESTS/$test");
+ $strap->analyze_file(File::Spec->catfile($SAMPLE_TESTS, $test));
is_deeply(\@out, $expect, "$test callback");
}
diff --git a/lib/Test/Harness/t/strap-analyze.t b/lib/Test/Harness/t/strap-analyze.t
index c3e3d1e13b..06c0966e6e 100644
--- a/lib/Test/Harness/t/strap-analyze.t
+++ b/lib/Test/Harness/t/strap-analyze.t
@@ -10,20 +10,18 @@ BEGIN {
}
}
-use File::Spec::Functions;
-
-my $SAMPLE_TESTS = $ENV{PERL_CORE}
- ? catdir(curdir(), 'lib', 'sample-tests')
- : catdir(curdir(), 't', 'sample-tests');
-
use strict;
use Test::More;
+use File::Spec;
+
+my $Curdir = File::Spec->curdir;
+my $SAMPLE_TESTS = $ENV{PERL_CORE}
+ ? File::Spec->catdir($Curdir, 'lib', 'sample-tests')
+ : File::Spec->catdir($Curdir, 't', 'sample-tests');
-if ($^O eq 'MacOS') {
- plan skip_all => "Exit status broken on Mac OS";
-}
-my $IsVMS = $^O eq 'VMS';
+my $IsMacPerl = $^O eq 'MacOS';
+my $IsVMS = $^O eq 'VMS';
# VMS uses native, not POSIX, exit codes.
my $die_exit = $IsVMS ? 44 : 1;
@@ -444,17 +442,14 @@ my %samples = (
},
);
-plan tests => (keys(%samples) * 3) + 3;
+plan tests => (keys(%samples) * 4) + 3;
use_ok('Test::Harness::Straps');
$SIG{__WARN__} = sub {
- warn @_ unless $_[0] =~ /^Enourmous test number/ ||
+ warn @_ unless $_[0] =~ /^Enormous test number/ ||
$_[0] =~ /^Can't detailize/
};
-
-$SAMPLE_TESTS = VMS::Filespec::unixify($SAMPLE_TESTS) if $^O eq 'VMS';
-
while( my($test, $expect) = each %samples ) {
for (0..$#{$expect->{details}}) {
$expect->{details}[$_]{type} = ''
@@ -465,20 +460,29 @@ while( my($test, $expect) = each %samples ) {
unless exists $expect->{details}[$_]{reason};
}
+ my $test_path = File::Spec->catfile($SAMPLE_TESTS, $test);
my $strap = Test::Harness::Straps->new;
- my %results = $strap->analyze_file($^O eq 'MacOS' ?
- catfile($SAMPLE_TESTS, $test) :
- "$SAMPLE_TESTS/$test");
+ my %results = $strap->analyze_file($test_path);
is_deeply($results{details}, $expect->{details}, "$test details" );
delete $expect->{details};
delete $results{details};
- # We can only check if it's zero or non-zero.
- is( !!$results{'wait'}, !!$expect->{'wait'}, 'wait status' );
- delete $results{'wait'};
- delete $expect->{'wait'};
+ SKIP: {
+ skip '$? unreliable in MacPerl', 2 if $IsMacPerl;
+
+ # We can only check if it's zero or non-zero.
+ is( !!$results{'wait'}, !!$expect->{'wait'}, 'wait status' );
+ delete $results{'wait'};
+ delete $expect->{'wait'};
+
+ # Have to check the exit status seperately so we can skip it
+ # in MacPerl.
+ is( $results{'exit'}, $expect->{'exit'} );
+ delete $results{'exit'};
+ delete $expect->{'exit'};
+ }
is_deeply(\%results, $expect, " the rest $test" );
}
diff --git a/lib/Test/Harness/t/test-harness.t b/lib/Test/Harness/t/test-harness.t
index 1e9f58ddb5..c04e2e2cfa 100644
--- a/lib/Test/Harness/t/test-harness.t
+++ b/lib/Test/Harness/t/test-harness.t
@@ -10,13 +10,14 @@ BEGIN {
}
}
-use File::Spec::Functions;
+use strict;
+use File::Spec;
+my $Curdir = File::Spec->curdir;
my $SAMPLE_TESTS = $ENV{PERL_CORE}
- ? catdir(curdir(), 'lib', 'sample-tests')
- : catdir(curdir(), 't', 'sample-tests');
+ ? File::Spec->catdir($Curdir, 'lib', 'sample-tests')
+ : File::Spec->catdir($Curdir, 't', 'sample-tests');
-use strict;
# For shutting up Test::Harness.
# Has to work on 5.004 which doesn't have Tie::StdHandle.
@@ -39,11 +40,11 @@ package main;
use Test::More;
-my $IsVMS = $^O eq 'VMS';
-my $IsMacOS = $^O eq 'MacOS';
+my $IsMacPerl = $^O eq 'MacOS';
+my $IsVMS = $^O eq 'VMS';
# VMS uses native, not POSIX, exit codes.
-my $die_estat = $IsVMS ? 44 : $IsMacOS ? 0 : 1;
+my $die_estat = $IsVMS ? 44 : 1;
my %samples = (
simple => {
@@ -415,7 +416,7 @@ my %samples = (
},
);
-plan tests => (keys(%samples) * 7) + 1;
+plan tests => (keys(%samples) * 8) + 1;
use Test::Harness;
use_ok('Test::Harness');
@@ -423,22 +424,23 @@ use_ok('Test::Harness');
tie *NULL, 'My::Dev::Null' or die $!;
-$SAMPLE_TESTS = VMS::Filespec::unixify($SAMPLE_TESTS) if $^O eq 'VMS';
-
while (my($test, $expect) = each %samples) {
# _run_all_tests() runs the tests but skips the formatting.
my($totals, $failed);
- my $warning;
+ my $warning = '';
+ my $test_path = File::Spec->catfile($SAMPLE_TESTS, $test);
+
eval {
select NULL; # _run_all_tests() isn't as quiet as it should be.
local $SIG{__WARN__} = sub { $warning .= join '', @_; };
($totals, $failed) =
- Test::Harness::_run_all_tests($^O eq 'MacOS' ?
- catfile($SAMPLE_TESTS, $test) :
- "$SAMPLE_TESTS/$test");
+ Test::Harness::_run_all_tests($test_path);
};
select STDOUT;
+ # $? is unreliable in MacPerl, so we'll simply fudge it.
+ $failed->{estat} = $die_estat if $IsMacPerl and $failed;
+
SKIP: {
skip "special tests for bailout", 1 unless $test eq 'bailout';
like( $@, '/Further testing stopped: GERONI/i' );
@@ -453,9 +455,7 @@ while (my($test, $expect) = each %samples) {
is_deeply( {map { $_=>$totals->{$_} } keys %{$expect->{total}}},
$expect->{total},
"$test - totals" );
- is_deeply( {map { $_=>$failed->{$^O eq 'MacOS' ?
- catfile($SAMPLE_TESTS, $test) :
- "$SAMPLE_TESTS/$test"}{$_} }
+ is_deeply( {map { $_=>$failed->{$test_path}{$_} }
keys %{$expect->{failed}}},
$expect->{failed},
"$test - failed" );
@@ -464,12 +464,16 @@ while (my($test, $expect) = each %samples) {
SKIP: {
skip "special tests for bignum", 1 unless $test eq 'bignum';
is( $warning, <<WARN );
-Enourmous test number seen [test 100001]
+Enormous test number seen [test 100001]
Can't detailize, too big.
-Enourmous test number seen [test 136211425]
+Enormous test number seen [test 136211425]
Can't detailize, too big.
WARN
}
+ SKIP: {
+ skip "bignum has known warnings", 1 if $test eq 'bignum';
+ is( $warning, '' );
+ }
}