Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

darobin (1316)

darobin
  (email not shown publicly)
http://berjon.com/

Journal of darobin (1316)

Thursday November 29, 2001
03:43 PM

Colourful Test::Harness

[ #1424 ]

I've been playing with tests recently, and I must say that I've been missing some readability in the output at times. So at some point I thought that if I could get a green ok and a red fail, then I'd be quite happy.

I made a small patch to Test::Harness that uses Term::ANSIColor to do exactly that. I'm sure it could do a lot more, and that I've missed some places of interest in the process. But Test::Harness is rather convoluted and not entirely readable, so I decided to leave it at that.

I won't submit it to p5p because I don't think it stands a chance of being accepted, especially as ANSIColor can't produce fully portable escapes and I don't feel like investigating dozens of platforms (also I'd rather live without those "we don't need no stinking colours" flames that'll prolly come up)

So in case someone's interested, here's the patch against version 1.25. As I said it's incomplete, but if you improve on it I'd be delighted to have a copy of your improvements.

--- /home/perl/lib/perl5/5.6.1/Test/Harness.pm.old Thu Nov 29 21:15:11 2001
+++ /home/perl/lib/perl5/5.6.1/Test/Harness.pm Thu Nov 29 21:42:49 2001
@@ -7,6 +7,7 @@
use Exporter;
use Benchmark;
use Config;
+use Term::ANSIColor qw(:constants);
use strict;

 
use vars qw($VERSION $Verbose $Switches $Have_Devel_Corestack $Curtest
@@ -20,7 +21,7 @@

 
$Have_Devel_Corestack = 0;

 
-$VERSION = 1.25;
+$VERSION = '1.25_robin';

 
$ENV{HARNESS_ACTIVE} = 1;

 
@@ -476,7 +477,7 @@
if $test{bonus};
print "$test{ml}ok, ".join(', ', @msg)."\n";
} elsif ($test{max}) {
- print "$test{ml}ok\n";
+ print GREEN . "$test{ml}ok" . RESET . "\n"; ### robin
} elsif (defined $test{skip_reason}) {
print "skipped: $test{skip_reason}\n";
$tot{skipped}++;
@@ -984,10 +985,10 @@
$last = $_;
}
local $" = ", ";
- push @result, "FAILED tests @canon\n";
+ push @result, RED, "FAILED tests @canon" . RESET . "\n"; ### robin
$canon = join ' ', @canon;
} else {
- push @result, "FAILED test $last\n";
+ push @result, RED . "FAILED test $last" . RESET . "\n"; ### robin
$canon = $last;
}

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • ... in the temporal convergence irony sense.

    My latest article recommends (among other things) that someone come up with a giant yellow ASCII smiley face for Test::Harness to display when everything succeeds.

    Of course, Jarkko will probably submit a patch to include EBCDIC platforms. I always forget about that.