line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TAP::Formatter::Color; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1391
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
83
|
|
4
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
166
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
20
|
use constant IS_WIN32 => ( $^O =~ /^(MS)?Win32$/ ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
228
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
22
|
use base 'TAP::Object'; |
|
3
|
|
|
|
|
37
|
|
|
3
|
|
|
|
|
582
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $NO_COLOR; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BEGIN { |
13
|
3
|
|
|
3
|
|
11
|
$NO_COLOR = 0; |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
|
|
177
|
eval 'require Term::ANSIColor'; |
16
|
3
|
50
|
|
|
|
22953
|
if ($@) { |
17
|
0
|
|
|
|
|
0
|
$NO_COLOR = $@; |
18
|
|
|
|
|
|
|
}; |
19
|
3
|
50
|
|
|
|
15
|
if (IS_WIN32) { |
20
|
0
|
|
|
|
|
0
|
eval 'use Win32::Console::ANSI'; |
21
|
0
|
0
|
|
|
|
0
|
if ($@) { |
22
|
0
|
|
|
|
|
0
|
$NO_COLOR = $@; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
3
|
50
|
|
|
|
11
|
if ($NO_COLOR) { |
27
|
0
|
|
|
|
|
0
|
*set_color = sub { }; |
28
|
|
|
|
|
|
|
} else { |
29
|
|
|
|
|
|
|
*set_color = sub { |
30
|
0
|
|
|
0
|
|
0
|
my ( $self, $output, $color ) = @_; |
31
|
0
|
|
|
|
|
0
|
$output->( Term::ANSIColor::color($color) ); |
32
|
3
|
|
|
|
|
402
|
}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
TAP::Formatter::Color - Run Perl test scripts with color |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 VERSION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Version 3.40_01 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our $VERSION = '3.40_01'; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Note that this harness is I. You may not like the colors I've |
51
|
|
|
|
|
|
|
chosen and I haven't yet provided an easy way to override them. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This test harness is the same as L, but test results are output |
54
|
|
|
|
|
|
|
in color. Passing tests are printed in green. Failing tests are in red. |
55
|
|
|
|
|
|
|
Skipped tests are blue on a white background and TODO tests are printed in |
56
|
|
|
|
|
|
|
white. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
If L cannot be found (and L if running |
59
|
|
|
|
|
|
|
under Windows) tests will be run without color. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNOPSIS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
use TAP::Formatter::Color; |
64
|
|
|
|
|
|
|
my $harness = TAP::Formatter::Color->new( \%args ); |
65
|
|
|
|
|
|
|
$harness->runtests(@tests); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 METHODS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 Class Methods |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head3 C |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
The constructor returns a new C object. If |
74
|
|
|
|
|
|
|
L is not installed, returns undef. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# new() implementation supplied by TAP::Object |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _initialize { |
81
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
2
|
50
|
|
|
|
8
|
if ($NO_COLOR) { |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# shorten that message a bit |
86
|
0
|
|
|
|
|
0
|
( my $error = $NO_COLOR ) =~ s/ in \@INC .*//s; |
87
|
0
|
|
|
|
|
0
|
warn "Note: Cannot run tests in color: $error\n"; |
88
|
0
|
|
|
|
|
0
|
return; # abort object construction |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
2
|
|
|
|
|
21
|
return $self; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
############################################################################## |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head3 C |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Test::Formatter::Color->can_color() |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns a boolean indicating whether or not this module can actually |
101
|
|
|
|
|
|
|
generate colored output. This will be false if it could not load the |
102
|
|
|
|
|
|
|
modules needed for the current platform. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub can_color { |
107
|
0
|
|
|
0
|
1
|
|
return !$NO_COLOR; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head3 C |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Set the output color. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |