summaryrefslogtreecommitdiff
path: root/lib/Test
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-06-27 12:46:44 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-06-27 12:46:44 +0000
commit43ef773bf404929508ebcd1d5537829ee65ae26f (patch)
treea2e2ace7e985321255186df0a7bbd4791dd5cadd /lib/Test
parentf8daf111cf97dcea4d3f7a99b328e7928e16363c (diff)
downloadperl-43ef773bf404929508ebcd1d5537829ee65ae26f.tar.gz
Upgrade to Test::Harness 2.52
p4raw-id: //depot/perl@24989
Diffstat (limited to 'lib/Test')
-rw-r--r--lib/Test/Harness.pm49
-rw-r--r--lib/Test/Harness/Changes18
-rw-r--r--lib/Test/Harness/bin/prove8
3 files changed, 58 insertions, 17 deletions
diff --git a/lib/Test/Harness.pm b/lib/Test/Harness.pm
index 07e612f4ea..05a3e1cf6c 100644
--- a/lib/Test/Harness.pm
+++ b/lib/Test/Harness.pm
@@ -10,12 +10,6 @@ use Benchmark;
use Config;
use strict;
-use vars '$has_time_hires';
-
-BEGIN {
- eval "use Time::HiRes 'time'";
- $has_time_hires = !$@;
-}
use vars qw(
$VERSION
@@ -24,21 +18,28 @@ use vars qw(
$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.50
+Version 2.52
=cut
-$VERSION = "2.50";
+$VERSION = "2.52";
# Backwards compatibility for exportable variable names.
*verbose = *Verbose;
@@ -72,6 +73,7 @@ $Debug = $ENV{HARNESS_DEBUG} || 0;
$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
@@ -126,6 +128,11 @@ The package variable C<$Test::Harness::switches> is exportable and can be
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
@@ -345,12 +352,22 @@ sub _run_all_tests {
if ( $Test::Harness::Debug ) {
print "# Running: ", $Strap->_command_line($tfile), "\n";
}
- my $test_start_time = time;
+ my $test_start_time = $Timer ? time : 0;
my %results = $Strap->analyze_file($tfile) or
do { warn $Strap->{error}, "\n"; next };
- my $test_end_time = time;
- my $elapsed = $test_end_time - $test_start_time;
- $elapsed = $has_time_hires ? sprintf( " %8.3fs", $elapsed ) : "";
+ 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} }
@@ -650,12 +667,12 @@ sub _print_ml {
}
-# 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;
}
}
diff --git a/lib/Test/Harness/Changes b/lib/Test/Harness/Changes
index 6efac351da..cb6cf4f0dc 100644
--- a/lib/Test/Harness/Changes
+++ b/lib/Test/Harness/Changes
@@ -1,5 +1,23 @@
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.
diff --git a/lib/Test/Harness/bin/prove b/lib/Test/Harness/bin/prove
index 3b109d924c..ee62afbc3e 100644
--- a/lib/Test/Harness/bin/prove
+++ b/lib/Test/Harness/bin/prove
@@ -40,6 +40,7 @@ GetOptions(
'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@' => \@ext,
@@ -179,6 +180,7 @@ Options:
-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 warning mode.
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 @@ Andy Lester C<< <andy@petdance.com> >>
=head1 COPYRIGHT
-Copyright 2003 by Andy Lester C<< <andy@petdance.com> >>.
+Copyright 2005 by Andy Lester C<< <andy@petdance.com> >>.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.