develooper Front page | perl.perl5.porters | Postings from October 2007

Test::Harness feature suggestion

Thread Next
From:
H.Merijn Brand
Date:
October 24, 2007 03:19
Subject:
Test::Harness feature suggestion
Message ID:
20071024101926.2bdbebe9@pc09.procura.nl
In chasing down a bug in the CORE test suite, I wanted 'make TEST' to
print the TIME next to 'ok' and found that t/TEST already supported a
way to show the elapsed time though the $HARNESS_TIMER environment.

I made this change to t/TEST:
--8<---
--- -   2007-10-24 12:16:04.091354000 +0200
+++ t/TEST      2007-10-24 12:15:50.000000000 +0200
@@ -496,8 +496,12 @@ EOT
        else {
            if ($max) {
                my $elapsed;
-               if ( $show_elapsed_time ) {
-                   $elapsed = sprintf( " %8.0f ms", (Time::HiRes::time() - $test_start_time) * 1000 );
+               if ( $show_elapsed_time eq "time" ) {
+                   my @now = localtime;
+                   $elapsed = sprintf " %02d:%02d:%02d", (localtime)[2,1,0];
+               }
+               elsif ( $show_elapsed_time ) {
+                   $elapsed = sprintf " %8.0f ms", (Time::HiRes::time() - $test_start_time) * 1000;
                }
                else {
                    $elapsed = "";
-->8---

but as t/TEST is a somewhat modified descendant of Harness.pm, I guess
a more generic change might be in order

pc09:/pro/3gl/CPAN/perl-current/t 136 > env HARNESS_TIMER=0 ./TEST op/ver.t
t/op/ver....ok
All tests successful.
u=0.00  s=0.00  cu=0.02  cs=0.00  scripts=1  tests=53
pc09:/pro/3gl/CPAN/perl-current/t 137 > env HARNESS_TIMER=1 ./TEST op/ver.t
t/op/ver....ok       26 ms
All tests successful.
u=0.02  s=0.00  cu=0.02  cs=0.00  scripts=1  tests=53
pc09:/pro/3gl/CPAN/perl-current/t 138 > env HARNESS_TIMER=time ./TEST op/ver.t
t/op/ver....ok 12:18:46
All tests successful.
u=0.02  s=0.00  cu=0.02  cs=0.00  scripts=1  tests=53
pc09:/pro/3gl/CPAN/perl-current/t 139 >

-- 
H.Merijn Brand         Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using & porting perl 5.6.2, 5.8.x, 5.10.x  on HP-UX 10.20, 11.00, 11.11,
& 11.23, SuSE 10.1 & 10.2, AIX 5.2, and Cygwin.       http://qa.perl.org
http://mirrors.develooper.com/hpux/            http://www.test-smoke.org
                        http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About