line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TAP::Parser::SourceHandler::RawTAP; |
2
|
|
|
|
|
|
|
|
3
|
33
|
|
|
33
|
|
2479
|
use strict; |
|
33
|
|
|
|
|
46
|
|
|
33
|
|
|
|
|
767
|
|
4
|
33
|
|
|
33
|
|
115
|
use warnings; |
|
33
|
|
|
|
|
41
|
|
|
33
|
|
|
|
|
646
|
|
5
|
|
|
|
|
|
|
|
6
|
33
|
|
|
33
|
|
118
|
use TAP::Parser::IteratorFactory (); |
|
33
|
|
|
|
|
43
|
|
|
33
|
|
|
|
|
359
|
|
7
|
33
|
|
|
33
|
|
11817
|
use TAP::Parser::Iterator::Array (); |
|
33
|
|
|
|
|
58
|
|
|
33
|
|
|
|
|
554
|
|
8
|
|
|
|
|
|
|
|
9
|
33
|
|
|
33
|
|
262
|
use base 'TAP::Parser::SourceHandler'; |
|
33
|
|
|
|
|
34
|
|
|
33
|
|
|
|
|
9180
|
|
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.39 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '3.39'; |
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
|
499
|
my ( $class, $src ) = @_; |
69
|
307
|
|
|
|
|
714
|
my $meta = $src->meta; |
70
|
|
|
|
|
|
|
|
71
|
307
|
100
|
|
|
|
1019
|
return 0 if $meta->{file}; |
72
|
89
|
100
|
|
|
|
198
|
if ( $meta->{is_scalar} ) { |
|
|
100
|
|
|
|
|
|
73
|
66
|
100
|
|
|
|
137
|
return 0 unless $meta->{has_newlines}; |
74
|
65
|
100
|
|
|
|
58
|
return 0.9 if ${ $src->raw } =~ /\d\.\.\d/; |
|
65
|
|
|
|
|
107
|
|
75
|
4
|
100
|
|
|
|
6
|
return 0.7 if ${ $src->raw } =~ /ok/; |
|
4
|
|
|
|
|
9
|
|
76
|
2
|
|
|
|
|
5
|
return 0.3; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
elsif ( $meta->{is_array} ) { |
79
|
4
|
|
|
|
|
14
|
return 0.5; |
80
|
|
|
|
|
|
|
} |
81
|
19
|
|
|
|
|
44
|
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
|
81
|
my ( $class, $src ) = @_; |
97
|
66
|
|
|
|
|
122
|
my $meta = $src->meta; |
98
|
|
|
|
|
|
|
|
99
|
66
|
|
|
|
|
65
|
my $tap_array; |
100
|
66
|
100
|
|
|
|
122
|
if ( $meta->{is_scalar} ) { |
|
|
50
|
|
|
|
|
|
101
|
63
|
|
|
|
|
62
|
$tap_array = [ split "\n" => ${ $src->raw } ]; |
|
63
|
|
|
|
|
127
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
elsif ( $meta->{is_array} ) { |
104
|
3
|
|
|
|
|
7
|
$tap_array = $src->raw; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
66
|
50
|
|
|
|
132
|
$class->_croak('No raw TAP found in $source->raw') |
108
|
|
|
|
|
|
|
unless scalar $tap_array; |
109
|
|
|
|
|
|
|
|
110
|
66
|
|
|
|
|
235
|
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 |