| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package TAP::Formatter::TextMate; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
182755
|
use warnings; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
73
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
69
|
|
|
5
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
361
|
|
|
6
|
2
|
|
|
2
|
|
1381
|
use TAP::Formatter::TextMate::Session; |
|
|
2
|
|
|
|
|
44
|
|
|
|
2
|
|
|
|
|
109
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.1'; |
|
9
|
2
|
|
|
2
|
|
147
|
use base 'TAP::Formatter::Console'; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
2525
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
TAP::Formatter::TextMate - Generate TextMate compatible test output |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This document describes TAP::Formatter::TextMate version 0.1 |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Create a TextMate command that looks something like this: |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
test='' |
|
24
|
|
|
|
|
|
|
opts='-rb' |
|
25
|
|
|
|
|
|
|
if [ ${TM_FILEPATH:(-2)} == '.t' ] ; then |
|
26
|
|
|
|
|
|
|
test=`echo $TM_FILEPATH | perl -pe "s{^$TM_PROJECT_DIRECTORY/+}{}"` |
|
27
|
|
|
|
|
|
|
opts='-b' |
|
28
|
|
|
|
|
|
|
fi |
|
29
|
|
|
|
|
|
|
cd $TM_PROJECT_DIRECTORY && prove --merge --formatter TAP::Formatter::TextMate $opts $test |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Generates TextMate compatible HTML test output. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 INTERFACE |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 C |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Called by Test::Harness before any test output is generated. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub prepare { |
|
44
|
1
|
|
|
1
|
1
|
1654
|
my ( $self, @tests ) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
6
|
my $html = $self->_html; |
|
47
|
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
58
|
$self->_raw_output( |
|
49
|
|
|
|
|
|
|
$html->open( 'html' ), |
|
50
|
|
|
|
|
|
|
$html->head( [ \'style', $self->_stylesheet ] ), |
|
51
|
|
|
|
|
|
|
$html->open( 'body' ), "\n" |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
138
|
$self->SUPER::prepare( @tests ); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head3 C |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Called to create a new test session. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub open_test { |
|
64
|
1
|
|
|
1
|
1
|
1013
|
my ( $self, $test, $parser ) = @_; |
|
65
|
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
17
|
my $session = TAP::Formatter::TextMate::Session->new( |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
|
|
|
|
|
|
name => $test, |
|
69
|
|
|
|
|
|
|
formatter => $self, |
|
70
|
|
|
|
|
|
|
parser => $parser |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
14
|
$session->header; |
|
75
|
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
8
|
return $session; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head3 C |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$harness->summary( $aggregate ); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
C prints the summary report after all tests are run. The argument is |
|
84
|
|
|
|
|
|
|
an aggregate. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub summary { |
|
89
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $aggregate ) = @_; |
|
90
|
0
|
|
|
|
|
0
|
my $html = $self->_html; |
|
91
|
0
|
|
|
|
|
0
|
$self->SUPER::summary( $aggregate ); |
|
92
|
0
|
|
|
|
|
0
|
$self->_raw_output( $html->close( 'body' ), $html->close( 'html' ), "\n" ); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _html { |
|
96
|
5
|
|
|
5
|
|
9
|
my $self = shift; |
|
97
|
5
|
|
66
|
|
|
30
|
return $self->{_html} ||= HTML::Tiny->new; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _set_colors { |
|
101
|
2
|
|
|
2
|
|
334
|
my $self = shift; |
|
102
|
|
|
|
|
|
|
# red white on_blue reset |
|
103
|
2
|
|
|
|
|
9
|
for my $col ( @_ ) { |
|
104
|
2
|
50
|
|
|
|
20
|
if ( $col =~ /on_(\w+)/ ) { |
|
|
|
100
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
0
|
$self->{_bg} = $1; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
elsif ( $col eq 'reset' ) { |
|
108
|
1
|
|
|
|
|
8
|
$self->{_fg} = $self->{_bg} = undef; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
else { |
|
111
|
1
|
|
|
|
|
13
|
$self->{_fg} = $col; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub _newline { |
|
117
|
3
|
|
|
3
|
|
34
|
my $self = shift; |
|
118
|
3
|
100
|
|
|
|
42
|
$self->_output( "\n" ) if $self->{_nl}; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _output { |
|
122
|
4
|
|
|
4
|
|
234
|
my $self = shift; |
|
123
|
4
|
|
|
|
|
17
|
my $out = join( '', @_ ); |
|
124
|
4
|
|
|
|
|
12
|
my $html = $self->_html; |
|
125
|
4
|
|
|
|
|
161
|
my $br = $html->br; |
|
126
|
4
|
|
|
|
|
225
|
my $hr = $html->hr; |
|
127
|
4
|
|
|
|
|
114
|
$self->{_nl} = substr( $out, -1 ) ne "\n"; |
|
128
|
4
|
|
|
|
|
16
|
$out =~ s/\r//g; |
|
129
|
4
|
100
|
|
|
|
28
|
if ( $out =~ /^[\s-]+$/ ) { |
|
130
|
2
|
|
|
|
|
5
|
$out =~ s/-{5,}\s*/$hr/g; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
else { |
|
133
|
2
|
|
|
|
|
12
|
$out = $html->entity_encode( $out ); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
4
|
|
|
|
|
111
|
$out =~ s/\n/$br\n/g; |
|
136
|
4
|
|
|
|
|
12
|
my ( $bg, $fg ) = ( $self->{_bg}, $self->{_fg} ); |
|
137
|
|
|
|
|
|
|
|
|
138
|
4
|
100
|
66
|
|
|
37
|
if ( $bg || $fg ) { |
|
139
|
1
|
|
|
|
|
4
|
my @style = (); |
|
140
|
1
|
50
|
|
|
|
12
|
push @style, 'color: ' . $fg if $fg; |
|
141
|
1
|
50
|
|
|
|
12
|
push @style, 'background-color: ' . $bg if $bg; |
|
142
|
1
|
|
|
|
|
12
|
$out = $html->span( { style => join( ';', @style ) }, $out ); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
4
|
|
|
|
|
97
|
$self->_raw_output( $out ); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub _raw_output { |
|
148
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
149
|
0
|
|
|
|
|
0
|
print join '', @_; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub _stylesheet { |
|
153
|
1
|
|
|
1
|
|
35
|
return <
|
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
body, html { |
|
156
|
|
|
|
|
|
|
color: green; |
|
157
|
|
|
|
|
|
|
background-color: black; |
|
158
|
|
|
|
|
|
|
font-family: monospace; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
.fail { |
|
162
|
|
|
|
|
|
|
color: red; |
|
163
|
|
|
|
|
|
|
background: #222; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
CSS |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
1; |
|
170
|
|
|
|
|
|
|
__END__ |