From: Rafael Garcia-Suarez Date: Tue, 8 Jun 2004 18:02:59 +0000 (+0000) Subject: Upgrade to Test::Harness 2.42 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=42d29bacdf382e27adec405e14a6a255f0bd3149;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Test::Harness 2.42 p4raw-id: //depot/perl@22907 --- diff --git a/lib/Test/Harness.pm b/lib/Test/Harness.pm index 35ceaaa..b6e46a1 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.80 2003/12/31 02:39:21 andy Exp $ +# $Id: Harness.pm,v 1.85 2004/04/29 03:13:43 andy Exp $ package Test::Harness; @@ -29,13 +29,13 @@ Test::Harness - Run Perl standard test scripts with statistics =head1 VERSION -Version 2.40 +Version 2.42; - $Header: /home/cvs/test-harness/lib/Test/Harness.pm,v 1.80 2003/12/31 02:39:21 andy Exp $ + $Header: /home/cvs/test-harness/lib/Test/Harness.pm,v 1.85 2004/04/29 03:13:43 andy Exp $ =cut -$VERSION = '2.40'; +$VERSION = '2.42'; # Backwards compatibility for exportable variable names. *verbose = *Verbose; @@ -1124,6 +1124,7 @@ Here's how Test::Harness tests itself =head1 SEE ALSO +The included F utility for running test scripts from the command line, L and L for writing test scripts, L for the underlying timing routines, L to generate core dumps from failed tests and L for test coverage diff --git a/lib/Test/Harness/Changes b/lib/Test/Harness/Changes index 6427c6a..2ad03c0 100644 --- a/lib/Test/Harness/Changes +++ b/lib/Test/Harness/Changes @@ -1,6 +1,15 @@ Revision history for Perl extension Test::Harness -2.40 Tue Dec 30 20:38:59 CST 2003 +2.42 Wed Apr 28 22:13:11 CDT 2004 + [ENHANCEMENTS] + * prove -v now sets TEST_VERBOSE in case your tests rely on them. + * prove globs the command line, since Win32's shell doesn't. + + [FIXES] + * Cross-platform test fixes on t/prove-globbing.t + + +2.40 Tue Dec 30 20:38:59 CST 2003 [FIXES] * Test::Harness::Straps should now properly quote on VMS. @@ -14,16 +23,16 @@ Revision history for Perl extension Test::Harness underscores, to indicate such. * Gratuitous text-only changes in Test::Harness::Iterator. - + * All tests now do their use_ok() in a BEGIN block. Some of the use_ok() calls were too much of a hassle to put into a BEGIN block, so I changed them to regular use calls. -2.38 Mon Nov 24 22:36:18 CST 2003 +2.38 Mon Nov 24 22:36:18 CST 2003 Released. See changes below. -2.37_03 Tue Nov 18 23:51:38 CST 2003 +2.37_03 Tue Nov 18 23:51:38 CST 2003 [ENHANCEMENTS] * prove -V now shows the Perl version being used. * Now there's a HARNESS_DEBUG flag that shows diagnostics as the diff --git a/lib/Test/Harness/bin/prove b/lib/Test/Harness/bin/prove index 44a631b..3b109d9 100644 --- a/lib/Test/Harness/bin/prove +++ b/lib/Test/Harness/bin/prove @@ -30,21 +30,23 @@ Getopt::Long::Configure( "no_ignore_case" ); Getopt::Long::Configure( "bundling" ); GetOptions( 'b|blib' => \$blib, - 'd|debug' => \$Test::Harness::debug, + 'd|debug' => \$Test::Harness::debug, 'D|dry' => \$dry, 'h|help|?' => sub {pod2usage({-verbose => 1, -input => \*DATA}); exit}, 'H|man' => sub {pod2usage({-verbose => 2, -input => \*DATA}); exit}, 'I=s@' => \@includes, - 'l|lib' => \$lib, + 'l|lib' => \$lib, 'r|recurse' => \$recurse, 's|shuffle' => \$shuffle, - 't' => sub { unshift @switches, "-t" }, # Always want -t up front - 'T' => sub { unshift @switches, "-T" }, # Always want -T up front + 't' => sub { unshift @switches, "-t" }, # Always want -t up front + 'T' => sub { unshift @switches, "-T" }, # Always want -T up front 'v|verbose' => \$Test::Harness::verbose, 'V|version' => sub { print_version(); exit; }, 'ext=s@' => \@ext, ) or exit 1; +$ENV{TEST_VERBOSE} = 1 if $Test::Harness::verbose; + # Build up extensions regex @ext = map { split /,/ } @ext; s/^\.// foreach @ext; @@ -56,9 +58,9 @@ $ext_regex = qr/\.($ext_regex)$/; if ( $blib ) { my @blibdirs = blibdirs(); if ( @blibdirs ) { - unshift @includes, @blibdirs; + unshift @includes, @blibdirs; } else { - warn "No blib directories found.\n"; + warn "No blib directories found.\n"; } } @@ -74,14 +76,14 @@ print "# \$Test::Harness::Switches: $Test::Harness::Switches\n" if $Test::Harnes my @tests; @ARGV = File::Spec->curdir unless @ARGV; -push( @tests, -d $_ ? all_in( $_ ) : $_ ) for @ARGV; +push( @tests, -d $_ ? all_in( $_ ) : $_ ) for map { glob } @ARGV; if ( @tests ) { shuffle(@tests) if $shuffle; if ( $dry ) { print join( "\n", @tests, "" ); } else { - print "# ", scalar @tests, " tests to run\n" if $Test::Harness::debug; + print "# ", scalar @tests, " tests to run\n" if $Test::Harness::debug; runtests(@tests); } } @@ -123,19 +125,19 @@ sub shuffle { sub print_version { printf( "prove v%s, using Test::Harness v%s and Perl v%vd\n", - $VERSION, $Test::Harness::VERSION, $^V ); + $VERSION, $Test::Harness::VERSION, $^V ); } # Stolen directly from blib.pm sub blibdirs { my $dir = File::Spec->curdir; if ($^O eq 'VMS') { - ($dir = VMS::Filespec::unixify($dir)) =~ s-/\z--; + ($dir = VMS::Filespec::unixify($dir)) =~ s-/\z--; } my $archdir = "arch"; if ( $^O eq "MacOS" ) { - # Double up the MP::A so that it's not used only once. - $archdir = $MacPerl::Architecture = $MacPerl::Architecture; + # Double up the MP::A so that it's not used only once. + $archdir = $MacPerl::Architecture = $MacPerl::Architecture; } my $i = 5; @@ -144,10 +146,10 @@ sub blibdirs { my $blib_lib = File::Spec->catdir( $blib, "lib" ); my $blib_arch = File::Spec->catdir( $blib, $archdir ); - if ( -d $blib && -d $blib_arch && -d $blib_lib ) { - return ($blib_arch,$blib_lib); - } - $dir = File::Spec->catdir($dir, File::Spec->updir); + if ( -d $blib && -d $blib_arch && -d $blib_lib ) { + return ($blib_arch,$blib_lib); + } + $dir = File::Spec->catdir($dir, File::Spec->updir); } warn "$0: Cannot find blib\n"; return; @@ -166,17 +168,17 @@ prove [options] [files/directories] Options: -b, --blib Adds blib/lib to the path for your tests, a la "use blib". - -d, --debug Includes extra debugging information. + -d, --debug Includes extra debugging information. -D, --dry Dry run: Show the tests to run, but don't run them. --ext=x Extensions (defaults to .t) -h, --help Display this help -H, --man Longer manpage for prove -I Add libraries to @INC, as Perl's -I - -l, --lib Add lib to the path for your tests. + -l, --lib Add lib to the path for your tests. -r, --recurse Recursively descend into directories. -s, --shuffle Run the tests in a random order. - -T Enable tainting checks - -t Enable tainting warnings + -T Enable tainting checks + -t Enable tainting warnings -v, --verbose Display standard output of test scripts while running them. -V, --version Display version info @@ -292,7 +294,8 @@ Runs test programs under perl's -T taint mode. =head2 -v, --verbose -Display standard output of test scripts while running them. +Display standard output of test scripts while running them. Also sets +TEST_VERBOSE in case your tests rely on them. =head2 -V, --version diff --git a/lib/Test/Harness/t/prove-switches.t b/lib/Test/Harness/t/prove-switches.t index aa7ece9..36426df 100644 --- a/lib/Test/Harness/t/prove-switches.t +++ b/lib/Test/Harness/t/prove-switches.t @@ -27,7 +27,7 @@ CAPITAL_TAINT: { my @actual = qx/$prove -Ifirst -D -I second -Ithird -Tvdb/; my @expected = ( "# \$Test::Harness::Switches: -T -I$blib_arch -I$blib_lib -Ifirst -Isecond -Ithird\n" ); - array_match_ok( \@actual, \@expected, "Capital taint flags OK" ); + is_deeply( \@actual, \@expected, "Capital taint flags OK" ); } LOWERCASE_TAINT: { @@ -36,7 +36,7 @@ LOWERCASE_TAINT: { my @actual = qx/$prove -dD -Ifirst -I second -t -Ithird -vb/; my @expected = ( "# \$Test::Harness::Switches: -t -I$blib_arch -I$blib_lib -Ifirst -Isecond -Ithird\n" ); - array_match_ok( \@actual, \@expected, "Lowercase taint OK" ); + is_deeply( \@actual, \@expected, "Lowercase taint OK" ); } PROVE_SWITCHES: { @@ -45,7 +45,7 @@ PROVE_SWITCHES: { my @actual = qx/$prove -Ibork -Dd/; my @expected = ( "# \$Test::Harness::Switches: -I$blib_arch -I$blib_lib -Ifark -Ibork\n" ); - array_match_ok( \@actual, \@expected, "PROVE_SWITCHES OK" ); + is_deeply( \@actual, \@expected, "PROVE_SWITCHES OK" ); } PROVE_SWITCHES_L: { @@ -53,7 +53,7 @@ PROVE_SWITCHES_L: { my @actual = qx/$prove -l -Ibongo -Dd/; my @expected = ( "# \$Test::Harness::Switches: -Ilib -Ibongo\n" ); - array_match_ok( \@actual, \@expected, "PROVE_SWITCHES OK" ); + is_deeply( \@actual, \@expected, "PROVE_SWITCHES OK" ); } PROVE_SWITCHES_LB: { @@ -61,25 +61,5 @@ PROVE_SWITCHES_LB: { my @actual = qx/$prove -lb -Dd/; my @expected = ( "# \$Test::Harness::Switches: -Ilib -I$blib_arch -I$blib_lib\n" ); - array_match_ok( \@actual, \@expected, "PROVE_SWITCHES OK" ); -} - - -sub array_match_ok { - my $actual = shift; - my $expected = shift; - my $message = shift; - my $n = 0; - - my @actual = @$actual; - my @expected = @$expected; - - while ( @actual && @expected ) { - return ok( 0, "Differs at element $n: $message" ) if shift @actual ne shift @expected; - ++$n; - } - return ok( 0, "Too many actual: $message" ) if @actual; - return ok( 0, "Too many expected: $message" ) if @expected; - - return ok( 1, $message ); + is_deeply( \@actual, \@expected, "PROVE_SWITCHES OK" ); }