line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TAP::Parser::SourceHandler::RawTAP; |
2
|
|
|
|
|
|
|
|
3
|
33
|
|
|
33
|
|
2470
|
use strict; |
|
33
|
|
|
|
|
39
|
|
|
33
|
|
|
|
|
765
|
|
4
|
33
|
|
|
33
|
|
103
|
use warnings; |
|
33
|
|
|
|
|
38
|
|
|
33
|
|
|
|
|
664
|
|
5
|
|
|
|
|
|
|
|
6
|
33
|
|
|
33
|
|
174
|
use TAP::Parser::IteratorFactory (); |
|
33
|
|
|
|
|
41
|
|
|
33
|
|
|
|
|
356
|
|
7
|
33
|
|
|
33
|
|
11485
|
use TAP::Parser::Iterator::Array (); |
|
33
|
|
|
|
|
59
|
|
|
33
|
|
|
|
|
598
|
|
8
|
|
|
|
|
|
|
|
9
|
33
|
|
|
33
|
|
230
|
use base 'TAP::Parser::SourceHandler'; |
|
33
|
|
|
|
|
43
|
|
|
33
|
|
|
|
|
9311
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
TAP::Parser::IteratorFactory->register_handler(__PACKAGE__); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
TAP::Parser::SourceHandler::RawTAP - Stream output from raw TAP in a scalar/array ref. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 3.38 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '3.38'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use TAP::Parser::Source; |
28
|
|
|
|
|
|
|
use TAP::Parser::SourceHandler::RawTAP; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $source = TAP::Parser::Source->new->raw( \"1..1\nok 1\n" ); |
31
|
|
|
|
|
|
|
$source->assemble_meta; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $class = 'TAP::Parser::SourceHandler::RawTAP'; |
34
|
|
|
|
|
|
|
my $vote = $class->can_handle( $source ); |
35
|
|
|
|
|
|
|
my $iter = $class->make_iterator( $source ); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This is a I L - it has 2 jobs: |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1. Figure out if the L it's given is raw TAP output |
42
|
|
|
|
|
|
|
(L). |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
2. Creates an iterator for raw TAP output (L). |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Unless you're writing a plugin or subclassing L, you probably |
47
|
|
|
|
|
|
|
won't need to use this module directly. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 Class Methods |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head3 C |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $vote = $class->can_handle( $source ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Only votes if $source is an array, or a scalar with newlines. Casts the |
58
|
|
|
|
|
|
|
following votes: |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
0.9 if it's a scalar with '..' in it |
61
|
|
|
|
|
|
|
0.7 if it's a scalar with 'ok' in it |
62
|
|
|
|
|
|
|
0.3 if it's just a scalar with newlines |
63
|
|
|
|
|
|
|
0.5 if it's an array |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub can_handle { |
68
|
307
|
|
|
307
|
1
|
459
|
my ( $class, $src ) = @_; |
69
|
307
|
|
|
|
|
698
|
my $meta = $src->meta; |
70
|
|
|
|
|
|
|
|
71
|
307
|
100
|
|
|
|
1000
|
return 0 if $meta->{file}; |
72
|
89
|
100
|
|
|
|
201
|
if ( $meta->{is_scalar} ) { |
|
|
100
|
|
|
|
|
|
73
|
66
|
100
|
|
|
|
128
|
return 0 unless $meta->{has_newlines}; |
74
|
65
|
100
|
|
|
|
63
|
return 0.9 if ${ $src->raw } =~ /\d\.\.\d/; |
|
65
|
|
|
|
|
111
|
|
75
|
4
|
100
|
|
|
|
7
|
return 0.7 if ${ $src->raw } =~ /ok/; |
|
4
|
|
|
|
|
10
|
|
76
|
2
|
|
|
|
|
9
|
return 0.3; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
elsif ( $meta->{is_array} ) { |
79
|
4
|
|
|
|
|
13
|
return 0.5; |
80
|
|
|
|
|
|
|
} |
81
|
19
|
|
|
|
|
40
|
return 0; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head3 C |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $iterator = $class->make_iterator( $source ); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns a new L for the source. |
89
|
|
|
|
|
|
|
C<$source-Eraw> must be an array ref, or a scalar ref. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Cs on error. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub make_iterator { |
96
|
66
|
|
|
66
|
1
|
92
|
my ( $class, $src ) = @_; |
97
|
66
|
|
|
|
|
134
|
my $meta = $src->meta; |
98
|
|
|
|
|
|
|
|
99
|
66
|
|
|
|
|
60
|
my $tap_array; |
100
|
66
|
100
|
|
|
|
137
|
if ( $meta->{is_scalar} ) { |
|
|
50
|
|
|
|
|
|
101
|
63
|
|
|
|
|
60
|
$tap_array = [ split "\n" => ${ $src->raw } ]; |
|
63
|
|
|
|
|
109
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
elsif ( $meta->{is_array} ) { |
104
|
3
|
|
|
|
|
9
|
$tap_array = $src->raw; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
66
|
50
|
|
|
|
128
|
$class->_croak('No raw TAP found in $source->raw') |
108
|
|
|
|
|
|
|
unless scalar $tap_array; |
109
|
|
|
|
|
|
|
|
110
|
66
|
|
|
|
|
227
|
return TAP::Parser::Iterator::Array->new($tap_array); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SUBCLASSING |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Please see L for a subclassing overview. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SEE ALSO |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
L, |
122
|
|
|
|
|
|
|
L, |
123
|
|
|
|
|
|
|
L, |
124
|
|
|
|
|
|
|
L, |
125
|
|
|
|
|
|
|
L, |
126
|
|
|
|
|
|
|
L, |
127
|
|
|
|
|
|
|
L, |
128
|
|
|
|
|
|
|
L |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |