Permalink
Browse files

Add support for customisable colors.

Customising the colors using the environment variables.
  • Loading branch information...
1 parent c1195c8 commit 9d1696f690dce7f7496148a75523a1ac6100c5a5 @shlomif shlomif committed May 28, 2011
Showing with 24 additions and 2 deletions.
  1. +14 −2 lib/TAP/Formatter/Console.pm
  2. +10 −0 lib/Test/Harness.pm
@@ -70,16 +70,28 @@ sub _set_colors {
}
}
+sub _failure_color {
+ my ($self) = @_;
+
+ return $ENV{'HARNESS_SUMMARY_COL_FAIL'} || 'red';
+}
+
+sub _success_color {
+ my ($self) = @_;
+
+ return $ENV{'HARNESS_SUMMARY_COL_SUC'} || 'green';
+}
+
sub _output_success {
my ( $self, $msg ) = @_;
- $self->_set_colors('green');
+ $self->_set_colors( $self->_success_color() );
$self->_output($msg);
$self->_set_colors('reset');
}
sub _failure_output {
my $self = shift;
- $self->_set_colors('red');
+ $self->_set_colors( $self->_failure_color() );
my $out = join '', @_;
my $has_newline = chomp $out;
$self->_output($out);
View
@@ -545,6 +545,16 @@ Multiple options may be separated by colons:
Specifies a TAP::Harness subclass to be used in place of TAP::Harness.
+=item C<HARNESS_SUMMARY_COL_SUC>
+
+Determines the L<Term::ANSIColor> for the summary in case it is successful.
+This color defaults to C<'green'>.
+
+=item C<HARNESS_SUMMARY_COL_FAIL>
+
+Determines the L<Term::ANSIColor> for the failure in case it is successful.
+This color defaults to C<'red'>.
+
=back
=head1 Taint Mode

0 comments on commit 9d1696f

Please sign in to comment.