[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 8/5] tap: support colorization of testsuite progress output
From: |
Ralf Wildenhues |
Subject: |
Re: [PATCH 8/5] tap: support colorization of testsuite progress output |
Date: |
Mon, 18 Jul 2011 23:10:58 +0200 |
* Stefano Lattarini wrote on Mon, Jul 18, 2011 at 10:30:56AM CEST:
> * lib/tap-driver (%COLORS): New variable (definition extracted
> from `lib/am/check.am:$(am__tty_colors)', with some obvious
> adjustments.
> (report): Adjust to colorize console output when required,
> using ...
> (decorate_result): ... this new function.
> (colored): New function, used by the one above.
> * tests/tap-summary.test: Also run the checks when `color-tests'
> is in use.
> * tests/Makefile.am (XFAIL_TESTS): Remove `tap-color.test'.
OK once dependent changes are in, and with nits below addressed.
Thanks,
Ralf
> --- a/lib/tap-driver
> +++ b/lib/tap-driver
> +# Keep this in sync with `lib/am/check.am:$(am__tty_colors)'.
> +my %COLOR = (
> + red => '[0;31m',
I'm sure perl has a way to encode ESC without a literal ESC.
> + grn => '[0;32m',
> + lgn => '[1;32m',
> + blu => '[1;34m',
> + mgn => '[0;35m',
> + brg => '[1m',
> + std => '[m',
> +);
> @@ -211,17 +222,39 @@ sub stringify_test_result ($)
> +sub decorate_result ($)
> +{
> + return $_[0] unless $cfg{"color-tests"};
> + # Best way to simulate a 'switch' construct here.
Please don't, that only obfuscates the code. automake.in uses long
if ... else lists. If you don't like that, use a map.
> + for (@_)
> + {
> + $_ eq "ERROR" and return colored ('mgn', $_);
> + $_ eq "PASS" and return colored ('grn', $_);
> + $_ eq "XPASS" and return colored ('red', $_);
> + $_ eq "FAIL" and return colored ('red', $_);
> + $_ eq "XFAIL" and return colored ('lgn', $_);
> + $_ eq "SKIP" and return colored ('blu', $_);
> + return $_; # Don't colorize unknown stuff.
> + }
> +}
> +
> sub report ($;$)
> {
> my ($msg, $result, $explanation) = (undef, @_);
> if ($result =~ /^(?:X?(?:PASS|FAIL)|SKIP|ERROR)/)
> {
> - $msg = "$result: $test_script_name";
> + $msg = ": $test_script_name";
> add_test_result $result;
> }
> elsif ($result eq "#")
> {
> - $msg = "# $test_script_name:";
> + $msg = " $test_script_name:";
> }
> else
> {
> @@ -229,10 +262,11 @@ sub report ($;$)
> }
> $msg .= " $explanation" if defined $explanation;
> $msg .= "\n";
> - print OLDOUT $msg;
> + # Output on console might be colorized.
> + print OLDOUT decorate_result ($result) . $msg;
> # Log the result in the log file too, to help debugging (this is
> # especially true when said result is a TAP error or "Bail out!").
> - print $msg;
> + print $result . $msg;
> }
>
> sub testuite_error ($)
[...]
- Re: [PATCH 4/5] {test-protocols} tests defs: new auxiliary function 'count_test_results', (continued)
- [PATCH 5/5] {test-protocols} tap: add experimental TAP-aware driver, Stefano Lattarini, 2011/07/14
- Re: [GSoC] Some patches for testsuite harness improvements and TAP support introduction, Ralf Wildenhues, 2011/07/18
- [PATCH 6/5] tap: some preparatory refactoring (1), Stefano Lattarini, 2011/07/18
- [PATCH 7/5] tap: some preparatory refactoring (2), Stefano Lattarini, 2011/07/18
- [PATCH 8/5] tap: support colorization of testsuite progress output, Stefano Lattarini, 2011/07/18
- Re: [PATCH 8/5] tap: support colorization of testsuite progress output,
Ralf Wildenhues <=