line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Run::Plugin::ColorSummary; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1142910
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
65
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
37
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
43
|
use 5.008; |
|
2
|
|
|
|
|
10
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
469
|
use Moose; |
|
2
|
|
|
|
|
394501
|
|
|
2
|
|
|
|
|
11
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
12581
|
use MRO::Compat; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
30
|
|
11
|
2
|
|
|
2
|
|
1324
|
use Term::ANSIColor; |
|
2
|
|
|
|
|
11104
|
|
|
2
|
|
|
|
|
146
|
|
12
|
|
|
|
|
|
|
# Needed for ->autoflush() |
13
|
2
|
|
|
2
|
|
517
|
use IO::Handle; |
|
2
|
|
|
|
|
4537
|
|
|
2
|
|
|
|
|
596
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
extends('Test::Run::Base'); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Test::Run::Plugin::ColorSummary - A Test::Run plugin that |
20
|
|
|
|
|
|
|
colors the summary. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 VERSION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
0.0202 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '0.0202'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'summary_color_failure' => (is => "rw", isa => "Str"); |
31
|
|
|
|
|
|
|
has 'summary_color_success' => (is => "rw", isa => "Str"); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _get_failure_summary_color |
35
|
|
|
|
|
|
|
{ |
36
|
2
|
|
|
2
|
|
7
|
my $self = shift; |
37
|
2
|
|
66
|
|
|
77
|
return $self->summary_color_failure() || |
38
|
|
|
|
|
|
|
$self->_get_default_failure_summary_color(); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _get_default_failure_summary_color |
42
|
|
|
|
|
|
|
{ |
43
|
1
|
|
|
1
|
|
9
|
return "bold red"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _get_success_summary_color |
47
|
|
|
|
|
|
|
{ |
48
|
2
|
|
|
2
|
|
7
|
my $self = shift; |
49
|
2
|
|
66
|
|
|
80
|
return $self->summary_color_success() || |
50
|
|
|
|
|
|
|
$self->_get_default_success_summary_color(); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _get_default_success_summary_color |
54
|
|
|
|
|
|
|
{ |
55
|
1
|
|
|
1
|
|
10
|
return "bold blue"; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
package MyTestRun; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
use vars qw(@ISA); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
@ISA = (qw(Test::Run::Plugin::ColorSummary Test::Run::Obj)); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $tester = MyTestRun->new( |
67
|
|
|
|
|
|
|
{ |
68
|
|
|
|
|
|
|
test_files => |
69
|
|
|
|
|
|
|
[ |
70
|
|
|
|
|
|
|
"t/sample-tests/one-ok.t", |
71
|
|
|
|
|
|
|
"t/sample-tests/several-oks.t" |
72
|
|
|
|
|
|
|
], |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$tester->runtests(); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 EXTRA PARAMETERS TO NEW |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
We accept two new named parameters to the new constructor: |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 summary_color_success |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This is the color string for coloring the success line. The string itself |
85
|
|
|
|
|
|
|
conforms to the one specified in L<Term::ANSIColor>. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 summary_color_failure |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This is the color string for coloring the summary line in case of |
90
|
|
|
|
|
|
|
failure. The string itself conforms to the one specified |
91
|
|
|
|
|
|
|
in L<Term::ANSIColor>. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 FUNCTIONS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _report_success |
98
|
|
|
|
|
|
|
{ |
99
|
2
|
|
|
2
|
|
567394
|
my $self = shift; |
100
|
2
|
|
|
|
|
14
|
print color($self->_get_success_summary_color()); |
101
|
2
|
|
|
|
|
110
|
$self->next::method(); |
102
|
2
|
|
|
|
|
850
|
print color("reset"); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 $tester->_handle_runtests_error() |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
We override _handle_runtests_error() to colour the errors in red. The rest of |
108
|
|
|
|
|
|
|
the documentation is the code. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub _handle_runtests_error_text |
113
|
|
|
|
|
|
|
{ |
114
|
2
|
|
|
2
|
|
375371
|
my ($self, $args) = @_; |
115
|
|
|
|
|
|
|
|
116
|
2
|
|
|
|
|
16
|
my $text = $args->{'text'}; |
117
|
|
|
|
|
|
|
|
118
|
2
|
|
|
|
|
26
|
STDERR->autoflush(); |
119
|
2
|
|
|
|
|
119
|
$text =~ s{\n\z}{}; |
120
|
2
|
|
|
|
|
14
|
die color($self->_get_failure_summary_color()).$text.color("reset")."\n"; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 AUTHOR |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Shlomi Fish, L<http://www.shlomifish.org/> . |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 BUGS |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
132
|
|
|
|
|
|
|
C<bug-test-run-plugin-colorsummary@rt.cpan.org>, or through the web interface at |
133
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Run-Plugin-ColorSummary>. |
134
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
135
|
|
|
|
|
|
|
your bug as I make changes. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SUPPORT |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
perldoc Test::Run::Plugin::ColorSummary |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
You can also look for information at: |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=over 4 |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Test::Run::Plugin::ColorSummary> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * CPAN Ratings |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Test::Run::Plugin::ColorSummary> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test::Run::Plugin::ColorSummary> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * Search CPAN |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Test::Run::Plugin::ColorSummary/> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=back |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
The latest source of Test::Run::Plugin::ColorSummary is available from the |
168
|
|
|
|
|
|
|
Test::Run BerliOS Subversion repository: |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
L<https://svn.berlios.de/svnroot/repos/web-cpan/Test-Harness-NG/> |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 SEE ALSO |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
L<Test::Run::Obj>, L<Term::ANSIColor>, |
175
|
|
|
|
|
|
|
L<Test::Run::CmdLine::Plugin::ColorSummary>. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Copyright 2005 Shlomi Fish, all rights reserved. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This program is released under the MIT X11 License. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |
186
|
|
|
|
|
|
|
|