From: Gurusamy Sarathy Date: Mon, 22 Apr 2002 09:53:36 +0000 (+0000) Subject: a Test::Harness tweak to make the test lines show up prettier X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=98e3f270ffa30af1413b4c0412a1027dbc9b03ed;p=p5sagit%2Fp5-mst-13.2.git a Test::Harness tweak to make the test lines show up prettier p4raw-id: //depot/perl@16068 --- diff --git a/lib/Test/Harness.pm b/lib/Test/Harness.pm index 0dd0f28..23e7ed89a 100644 --- a/lib/Test/Harness.pm +++ b/lib/Test/Harness.pm @@ -36,6 +36,9 @@ my $Ignore_Exitcode = $ENV{HARNESS_IGNORE_EXITCODE}; my $Files_In_Dir = $ENV{HARNESS_FILELEAK_IN_DIR}; +my $Running_In_Perl_Tree = 0; +++$Running_In_Perl_Tree if -d "../t" and -f "../sv.c"; + my $Strap = Test::Harness::Straps->new; @ISA = ('Exporter'); @@ -599,7 +602,11 @@ sub _mk_leader { chomp($te); $te =~ s/\.\w+$/./; - if ($^O eq 'VMS') { $te =~ s/^.*\.t\./\[.t./s; } + if ($^O eq 'VMS') { + $te =~ s/^.*\.t\./\[.t./s; + } + $te =~ s,\\,/,g if $^O eq 'MSWin32'; + $te =~ s,^\.\./,/, if $Running_In_Perl_Tree; my $blank = (' ' x 77); my $leader = "$te" . '.' x ($width - length($te)); my $ml = ""; @@ -625,12 +632,15 @@ sub _leader_width { foreach (@_) { my $suf = /\.(\w+)$/ ? $1 : ''; my $len = length; + $len -= 2 if $Running_In_Perl_Tree and m{^\.\.[/\\]}; my $suflen = length $suf; $maxlen = $len if $len > $maxlen; $maxsuflen = $suflen if $suflen > $maxsuflen; } - # + 3 : we want three dots between the test name and the "ok" - return $maxlen + 3 - $maxsuflen; + # we want three dots between the test name and the "ok" for + # typical lengths, and just two dots if longer than 30 characters + $maxlen -= $maxsuflen; + return $maxlen + ($maxlen >= 30 ? 2 : 3); }