Change 25380 by [EMAIL PROTECTED] on 2005/09/10 21:03:36

        Integrate:
        [ 24932]
        Upgrade to Test::Harness 2.49_02
        
        [ 24941]
        Upgrade to Test::Harness 2.50
        
        [ 24989]
        Upgrade to Test::Harness 2.52

Affected files ...

... //depot/maint-5.8/perl/lib/Test/Harness.pm#16 integrate
... //depot/maint-5.8/perl/lib/Test/Harness/Changes#10 integrate
... //depot/maint-5.8/perl/lib/Test/Harness/Iterator.pm#5 integrate
... //depot/maint-5.8/perl/lib/Test/Harness/Straps.pm#13 integrate
... //depot/maint-5.8/perl/lib/Test/Harness/bin/prove#4 integrate
... //depot/maint-5.8/perl/lib/Test/Harness/t/strap-analyze.t#7 integrate
... //depot/maint-5.8/perl/lib/Test/Harness/t/test-harness.t#7 integrate

Differences ...

==== //depot/maint-5.8/perl/lib/Test/Harness.pm#16 (text) ====
Index: perl/lib/Test/Harness.pm
--- perl/lib/Test/Harness.pm#15~24324~  Mon Apr 25 08:04:43 2005
+++ perl/lib/Test/Harness.pm    Sat Sep 10 14:03:36 2005
@@ -10,6 +10,7 @@
 use Config;
 use strict;
 
+
 use vars qw(
     $VERSION 
     @ISA @EXPORT @EXPORT_OK 
@@ -17,21 +18,28 @@
     $verbose $switches $debug
     $Curtest
     $Columns 
+    $Timer
     $ML $Last_ML_Print
     $Strap
+    $has_time_hires
 );
 
+BEGIN {
+    eval "use Time::HiRes 'time'";
+    $has_time_hires = !$@;
+}
+
 =head1 NAME
 
 Test::Harness - Run Perl standard test scripts with statistics
 
 =head1 VERSION
 
-Version 2.48
+Version 2.52
 
 =cut
 
-$VERSION = "2.48";
+$VERSION = "2.52";
 
 # Backwards compatibility for exportable variable names.
 *verbose  = *Verbose;
@@ -65,6 +73,7 @@
 $Switches = "-w";
 $Columns  = $ENV{HARNESS_COLUMNS} || $ENV{COLUMNS} || 80;
 $Columns--;             # Some shells have trouble with a full line of text.
+$Timer    = $ENV{HARNESS_TIMER} || 0;
 
 =head1 SYNOPSIS
 
@@ -119,6 +128,11 @@
 used to set perl command line options used for running the test
 script(s). The default value is C<-w>. It overrides C<HARNESS_SWITCHES>.
 
+=item C<$Test::Harness::Timer>
+
+If set to true, and C<Time::HiRes> is available, print elapsed seconds
+after each test file.
+
 =back
 
 
@@ -321,7 +335,7 @@
                );
 
     my @dir_files = _globdir $Files_In_Dir if defined $Files_In_Dir;
-    my $t_start = new Benchmark;
+    my $run_start_time = new Benchmark;
 
     my $width = _leader_width(@tests);
     foreach my $tfile (@tests) {
@@ -337,8 +351,22 @@
         if ( $Test::Harness::Debug ) {
             print "# Running: ", $Strap->_command_line($tfile), "\n";
         }
+        my $test_start_time = $Timer ? time : 0;
         my %results = $Strap->analyze_file($tfile) or
           do { warn $Strap->{error}, "\n";  next };
+        my $elapsed;
+        if ( $Timer ) {
+            $elapsed = time - $test_start_time;
+            if ( $has_time_hires ) {
+                $elapsed = sprintf( " %8.3fs", $elapsed );
+            }
+            else {
+                $elapsed = sprintf( " %8ss", $elapsed ? $elapsed : "<1" );
+            }
+        }
+        else {
+            $elapsed = "";
+        }
 
         # state of the current test.
         my @failed = grep { !$results{details}[$_-1]{ok} }
@@ -364,19 +392,23 @@
         my($estatus, $wstatus) = @results{qw(exit wait)};
 
         if ($results{passing}) {
+            # XXX Combine these first two
             if ($test{max} and $test{skipped} + $test{bonus}) {
                 my @msg;
                 push(@msg, "$test{skipped}/$test{max} skipped: 
$test{skip_reason}")
                     if $test{skipped};
                 push(@msg, "$test{bonus}/$test{max} unexpectedly succeeded")
                     if $test{bonus};
-                print "$test{ml}ok\n        ".join(', ', @msg)."\n";
-            } elsif ($test{max}) {
-                print "$test{ml}ok\n";
-            } elsif (defined $test{skip_all} and length $test{skip_all}) {
+                print "$test{ml}ok$elapsed\n        ".join(', ', @msg)."\n";
+            }
+            elsif ( $test{max} ) {
+                print "$test{ml}ok$elapsed\n";
+            }
+            elsif ( defined $test{skip_all} and length $test{skip_all} ) {
                 print "skipped\n        all skipped: $test{skip_all}\n";
                 $tot{skipped}++;
-            } else {
+            }
+            else {
                 print "skipped\n        all skipped: no reason given\n";
                 $tot{skipped}++;
             }
@@ -414,7 +446,8 @@
                                              estat   => '',
                                              wstat   => '',
                                            };
-                } else {
+                }
+                else {
                     print "Don't know which tests failed: got $test{ok} ok, ".
                           "expected $test{max}\n";
                     $failedtests{$tfile} = { canon   => '??',
@@ -427,7 +460,8 @@
                                            };
                 }
                 $tot{bad}++;
-            } else {
+            }
+            else {
                 print "FAILED before any test output arrived\n";
                 $tot{bad}++;
                 $failedtests{$tfile} = { canon       => '??',
@@ -453,7 +487,7 @@
             }
         }
     } # foreach test
-    $tot{bench} = timediff(new Benchmark, $t_start);
+    $tot{bench} = timediff(new Benchmark, $run_start_time);
 
     $Strap->_restore_PERL5LIB;
 
@@ -478,13 +512,15 @@
     chomp($te);
     $te =~ s/\.\w+$/./;
 
-    if ($^O eq 'VMS') { $te =~ s/^.*\.t\./\[.t./s; }
-    my $blank = (' ' x 77);
+    if ($^O eq 'VMS') {
+        $te =~ s/^.*\.t\./\[.t./s;
+    }
     my $leader = "$te" . '.' x ($width - length($te));
     my $ml = "";
 
-    $ml = "\r$blank\r$leader"
-      if -t STDOUT and not $ENV{HARNESS_NOTTY} and not $Verbose;
+    if ( -t STDOUT and not $ENV{HARNESS_NOTTY} and not $Verbose ) {
+        $ml = "\r" . (' ' x 77) . "\r$leader"
+    }
 
     return($leader, $ml);
 }
@@ -521,13 +557,16 @@
 
     if (_all_ok($tot)) {
         print "All tests successful$bonusmsg.\n";
-    } elsif (!$tot->{tests}){
+    }
+    elsif (!$tot->{tests}){
         die "FAILED--no tests were run for some reason.\n";
-    } elsif (!$tot->{max}) {
+    }
+    elsif (!$tot->{max}) {
         my $blurb = $tot->{tests}==1 ? "script" : "scripts";
         die "FAILED--$tot->{tests} test $blurb could be run, ".
             "alas--no output ever seen\n";
-    } else {
+    }
+    else {
         $pct = sprintf("%.2f", $tot->{good} / $tot->{tests} * 100);
         my $percent_ok = 100*$tot->{ok}/$tot->{max};
         my $subpct = sprintf " %d/%d subtests failed, %.2f%% okay.",
@@ -627,12 +666,12 @@
 }
 
 
-# For slow connections, we save lots of bandwidth by printing only once
-# per second.
+# Print updates only once per second.
 sub _print_ml_less {
-    if ( $Last_ML_Print != time ) {
+    my $now = CORE::time;
+    if ( $Last_ML_Print != $now ) {
         _print_ml(@_);
-        $Last_ML_Print = time;
+        $Last_ML_Print = $now;
     }
 }
 
@@ -763,11 +802,7 @@
     if (@failed) {
         for (@failed, $failed[-1]) { # don't forget the last one
             if ($_ > $last+1 || $_ == $last) {
-                if ($min == $last) {
-                    push @canon, $last;
-                } else {
-                    push @canon, "$min-$last";
-                }
+                push @canon, ($min == $last) ? $last : "$min-$last";
                 $min = $_;
             }
             $last = $_;
@@ -775,7 +810,8 @@
         local $" = ", ";
         push @result, "FAILED tests @canon\n";
         $canon = join ' ', @canon;
-    } else {
+    }
+    else {
         push @result, "FAILED test $last\n";
         $canon = $last;
     }
@@ -783,7 +819,8 @@
     push @result, "\tFailed $failed/$max tests, ";
     if ($max) {
        push @result, sprintf("%.2f",100*(1-$failed/$max)), "% okay";
-    } else {
+    }
+    else {
        push @result, "?% okay";
     }
     my $ender = 's' x ($skipped > 1);
@@ -793,7 +830,8 @@
        if ($max) {
            my $goodper = sprintf("%.2f",100*($good/$max));
            $skipmsg .= "$goodper%)";
-       } else {
+        }
+        else {
            $skipmsg .= "?%)";
        }
        push @result, $skipmsg;

==== //depot/maint-5.8/perl/lib/Test/Harness/Changes#10 (text) ====
Index: perl/lib/Test/Harness/Changes
--- perl/lib/Test/Harness/Changes#9~24324~      Mon Apr 25 08:04:43 2005
+++ perl/lib/Test/Harness/Changes       Sat Sep 10 14:03:36 2005
@@ -1,5 +1,36 @@
 Revision history for Perl extension Test::Harness
 
+2.52 Sun Jun 26 23:05:19 CDT 2005
+    No changes
+
+2.51_02
+    [ENHANCEMENTS]
+    * The Test::Harness timer is now off by default.  Set HARNESS_TIMER
+      true if you want it.  Added --timer flag to prove.
+
+2.50_01
+    [FIXES]
+    * Call CORE::time() to figure out if we should print when we're
+      printing once per second.  Otherwise, we're using Time::HiRes'
+      version of it.  Thanks, Nicholas Clark.
+
+2.50 Tue Jun 21 14:32:12 CDT 2005
+    [FIXES]
+    * Added some includes in t/strap-analyze.t to make Cygwin happy.
+
+2.49_02 Tue Jun 21 09:54:44 CDT 2005
+    [FIXES]
+    * Added some includes in t/test_harness.t to make Cygwin happy.
+
+2.49_01 Fri Jun 10 15:37:31 CDT 2005
+    [ENHANCEMENTS]
+    * Now shows elapsed time in 1000ths of a second if Time::HiRes
+      is available.
+
+    [FIXES]
+    * Test::Harness::Iterator didn't have a 1; at the end.  Thanks to
+      Steve Peters for finding it.
+
 2.48    Fri Apr 22 22:41:46 CDT 2005
     Released after weeks of non-complaint.
 

==== //depot/maint-5.8/perl/lib/Test/Harness/Iterator.pm#5 (text) ====
Index: perl/lib/Test/Harness/Iterator.pm
--- perl/lib/Test/Harness/Iterator.pm#4~24143~  Sun Apr  3 07:49:04 2005
+++ perl/lib/Test/Harness/Iterator.pm   Sat Sep 10 14:03:36 2005
@@ -66,3 +66,5 @@
     my $self = shift;
     return $self->{array}->[$self->{idx}++];
 }
+
+"Steve Peters, Master Of True Value Finding, was here.";

==== //depot/maint-5.8/perl/lib/Test/Harness/Straps.pm#13 (text) ====
Index: perl/lib/Test/Harness/Straps.pm
--- perl/lib/Test/Harness/Straps.pm#12~24324~   Mon Apr 25 08:04:43 2005
+++ perl/lib/Test/Harness/Straps.pm     Sat Sep 10 14:03:36 2005
@@ -457,7 +457,8 @@
        # toss the ones that involve perl_root, the install location
         @inc = grep !/perl_root/i, @inc;
 
-    } elsif ( $self->{_is_win32} ) {
+    }
+    elsif ( $self->{_is_win32} ) {
        # Lose any trailing backslashes in the Win32 paths
        s/[\\\/+]$// foreach @inc;
     }

==== //depot/maint-5.8/perl/lib/Test/Harness/bin/prove#4 (text) ====
Index: perl/lib/Test/Harness/bin/prove
--- perl/lib/Test/Harness/bin/prove#3~22985~    Wed Jun 23 08:15:37 2004
+++ perl/lib/Test/Harness/bin/prove     Sat Sep 10 14:03:36 2005
@@ -40,6 +40,7 @@
     's|shuffle'     => \$shuffle,
     't'             => sub { unshift @switches, "-t" }, # Always want -t up 
front
     'T'             => sub { unshift @switches, "-T" }, # Always want -T up 
front
+    'timer'         => \$Test::Harness::Timer,
     'v|verbose'     => \$Test::Harness::verbose,
     'V|version'     => sub { print_version(); exit; },
     'ext=s@'        => [EMAIL PROTECTED],
@@ -179,6 +180,7 @@
     -s, --shuffle   Run the tests in a random order.
     -T              Enable tainting checks
     -t              Enable tainting warnings
+        --timer     Print elapsed time after each test file
     -v, --verbose   Display standard output of test scripts while running them.
     -V, --version   Display version info
 
@@ -292,6 +294,10 @@
 
 Runs test programs under perl's -T taint mode.
 
+=head2 --timer
+
+Print elapsed time after each test file
+
 =head2 -v, --verbose
 
 Display standard output of test scripts while running them.  Also sets
@@ -323,7 +329,7 @@
 
 =head1 COPYRIGHT
 
-Copyright 2003 by Andy Lester C<< <[EMAIL PROTECTED]> >>.
+Copyright 2005 by Andy Lester C<< <[EMAIL PROTECTED]> >>.
 
 This program is free software; you can redistribute it and/or 
 modify it under the same terms as Perl itself.

==== //depot/maint-5.8/perl/lib/Test/Harness/t/strap-analyze.t#7 (text) ====
Index: perl/lib/Test/Harness/t/strap-analyze.t
--- perl/lib/Test/Harness/t/strap-analyze.t#6~24324~    Mon Apr 25 08:04:43 2005
+++ perl/lib/Test/Harness/t/strap-analyze.t     Sat Sep 10 14:03:36 2005
@@ -547,6 +547,8 @@
 plan tests => (keys(%samples) * 5) + 3;
 
 use Test::Harness::Straps;
+my @_INC = map { qq{"-I$_"} } @INC;
+$Test::Harness::Switches = "@_INC -Mstrict";
 
 $SIG{__WARN__} = sub { 
     warn @_ unless $_[0] =~ /^Enormous test number/ ||

==== //depot/maint-5.8/perl/lib/Test/Harness/t/test-harness.t#7 (text) ====
Index: perl/lib/Test/Harness/t/test-harness.t
--- perl/lib/Test/Harness/t/test-harness.t#6~22022~     Wed Dec 31 05:41:17 2003
+++ perl/lib/Test/Harness/t/test-harness.t      Sat Sep 10 14:03:36 2005
@@ -472,7 +472,8 @@
 plan tests => (keys(%samples) * 8);
 
 use Test::Harness;
-$Test::Harness::Switches = '"-Mstrict"';
+my @_INC = map { qq{"-I$_"} } @INC;
+$Test::Harness::Switches = "@_INC -Mstrict";
 
 tie *NULL, 'Dev::Null' or die $!;
 
End of Patch.

Reply via email to