> On Tuesday 19 July 2011, Ralf Wildenhues wrote:
> Below is what I've squashed in. OK?
Sure, thanks!
> --- a/lib/tap-driver
> +++ b/lib/tap-driver
> @@ -230,17 +230,24 @@ sub colored ($$)
>
> sub decorate_result ($)
> {
> - return $_[0] unless $cfg{"color-tests"};
> - # Best way to simulate a 'switch' construct here.
> - for (@_)
> + my $result = shift;
> + return $result unless $cfg{"color-tests"};
> + my %color_for_result =
> + (
> + "ERROR" => 'mgn',
> + "PASS" => 'grn',
> + "XPASS" => 'red',
> + "FAIL" => 'red',
> + "XFAIL" => 'lgn',
> + "SKIP" => 'blu',
> + );
> + if (my $color = $color_for_result{$result})
> + {
> + return colored ($color, $result);
> + }
> + else
> {
> - $_ 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.
> + return $result; # Don't colorize unknown stuff.
> }
> }
>
>