summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-06-16 17:38:53 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-06-16 17:38:53 +0000
commit7a3152049c3b11217c72b149c0293284b6993763 (patch)
treece4b8b45d64ebc2639247336f0d453b672db1cbd /lib
parentee96af8ff6e9f715a42440fa2eb3e1834eb07e91 (diff)
downloadperl-7a3152049c3b11217c72b149c0293284b6993763.tar.gz
Make t/TEST and t/harness to test also the t/ tests
under the main lib/ and ext/ directories. Fix Test::Harness to dynamically change the width of its "foo/bar....ok" output. p4raw-id: //depot/perl@10634
Diffstat (limited to 'lib')
-rw-r--r--lib/Test/Harness.pm19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/Test/Harness.pm b/lib/Test/Harness.pm
index 556d01a421..5444a406cf 100644
--- a/lib/Test/Harness.pm
+++ b/lib/Test/Harness.pm
@@ -395,8 +395,16 @@ sub _run_all_tests {
my @dir_files = _globdir $Files_In_Dir if defined $Files_In_Dir;
my $t_start = new Benchmark;
+ my $maxlen;
+ foreach (@tests) {
+ my $len = length;
+ $maxlen = $len if $len > $maxlen;
+ }
+ # +3 : we want three dots between the test name and the "ok"
+ # -2 : the .t suffix
+ my $width = $maxlen + 3 - 2;
foreach my $tfile (@tests) {
- my($leader, $ml) = _mk_leader($tfile);
+ my($leader, $ml) = _mk_leader($tfile, $width);
print $leader;
my $fh = _open_test($tfile);
@@ -531,22 +539,23 @@ sub _run_all_tests {
=item B<_mk_leader>
- my($leader, $ml) = _mk_leader($test_file);
+ my($leader, $ml) = _mk_leader($test_file, $width);
Generates the 't/foo........' $leader for the given $test_file as well
as a similar version which will overwrite the current line (by use of
\r and such). $ml may be empty if Test::Harness doesn't think you're
-on TTY.
+on TTY. The width is the width of the "yada/blah..." string.
=cut
sub _mk_leader {
- my $te = shift;
+ my ($te, $width) = @_;
+
chop($te); # XXX chomp?
if ($^O eq 'VMS') { $te =~ s/^.*\.t\./\[.t./s; }
my $blank = (' ' x 77);
- my $leader = "$te" . '.' x (20 - length($te));
+ my $leader = "$te" . '.' x ($width - length($te));
my $ml = "";
$ml = "\r$blank\r$leader"