line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Harness::Parser; |
2
|
28
|
|
|
28
|
|
114826
|
use strict; |
|
28
|
|
|
|
|
30
|
|
|
28
|
|
|
|
|
686
|
|
3
|
28
|
|
|
28
|
|
84
|
use warnings; |
|
28
|
|
|
|
|
28
|
|
|
28
|
|
|
|
|
1008
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000012'; |
6
|
|
|
|
|
|
|
|
7
|
28
|
|
|
28
|
|
82
|
use Carp qw/croak/; |
|
28
|
|
|
|
|
325
|
|
|
28
|
|
|
|
|
1436
|
|
8
|
28
|
|
|
28
|
|
104
|
use Scalar::Util qw/blessed/; |
|
28
|
|
|
|
|
36
|
|
|
28
|
|
|
|
|
1058
|
|
9
|
|
|
|
|
|
|
|
10
|
28
|
|
|
28
|
|
106
|
use Test2::Util qw/pkg_to_file/; |
|
28
|
|
|
|
|
28
|
|
|
28
|
|
|
|
|
986
|
|
11
|
|
|
|
|
|
|
|
12
|
28
|
|
|
28
|
|
8957
|
use Test2::Event::ParserSelect; |
|
28
|
|
|
|
|
30
|
|
|
28
|
|
|
|
|
585
|
|
13
|
|
|
|
|
|
|
|
14
|
28
|
|
|
28
|
|
88
|
use Test2::Util::HashBase qw/proc job/; |
|
28
|
|
|
|
|
28
|
|
|
28
|
|
|
|
|
82
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
611
|
1
|
|
sub morph {} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub init { |
19
|
623
|
|
|
623
|
0
|
296461
|
my $self = shift; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
croak "'proc' is a required attribute" |
22
|
623
|
100
|
|
|
|
2167
|
unless $self->{+PROC}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
croak "'job' is a required attribute" |
25
|
621
|
100
|
|
|
|
1596
|
unless $self->{+JOB}; |
26
|
|
|
|
|
|
|
|
27
|
619
|
|
|
|
|
1803
|
$self->morph; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub step { |
31
|
10772
|
|
|
10772
|
1
|
9308
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
10772
|
|
|
|
|
28701
|
my $class = blessed($self); |
34
|
10772
|
|
|
|
|
29200
|
my $line = $self->proc->get_out_line(peek => 1); |
35
|
10772
|
100
|
|
|
|
18802
|
chomp $line if defined $line; |
36
|
10772
|
100
|
66
|
|
|
32884
|
return unless defined $line && length $line; |
37
|
|
|
|
|
|
|
|
38
|
611
|
50
|
33
|
|
|
5060
|
if ($class eq __PACKAGE__ && $line) { |
39
|
611
|
100
|
|
|
|
6613
|
if ($line =~ m/^T2_FORMATTER: (.+)$/) { |
40
|
346
|
|
|
|
|
3009
|
chomp(my $fmt = $1); |
41
|
346
|
|
|
|
|
1189
|
$fmt =~ s/[\r\s]+$//g; |
42
|
346
|
|
|
|
|
1309
|
my $class = "Test2::Harness::Parser::$fmt"; |
43
|
346
|
|
|
|
|
3174
|
require(pkg_to_file($class)); |
44
|
346
|
|
|
|
|
14658
|
bless($self, $class); |
45
|
346
|
|
|
|
|
3015
|
$self->morph; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Strip off the line, it has been processed |
48
|
346
|
|
|
|
|
1381
|
$self->proc->get_out_line; |
49
|
|
|
|
|
|
|
|
50
|
346
|
|
|
|
|
4593
|
return Test2::Event::ParserSelect->new( |
51
|
|
|
|
|
|
|
parser_class => $class, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
265
|
100
|
|
|
|
4037
|
if ($line =~ m/^\s*(ok\b|not ok\b|1\.\.\d+|Bail out!|TAP version|^\#.+)/) { |
56
|
263
|
|
|
|
|
21878
|
require Test2::Harness::Parser::TAP; |
57
|
263
|
|
|
|
|
2098
|
bless($self, 'Test2::Harness::Parser::TAP'); |
58
|
263
|
|
|
|
|
1828
|
$self->morph; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Do not strip off the line, we need the TAP parser to eat it. |
61
|
263
|
|
|
|
|
4384
|
return Test2::Event::ParserSelect->new( |
62
|
|
|
|
|
|
|
parser_class => 'Test2::Harness::Parser::TAP', |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
2
|
50
|
|
|
|
8
|
if ($class eq __PACKAGE__) { |
68
|
2
|
|
|
|
|
17
|
die 'You cannot use Test2::Harness::Parser itself, it must be subclassed'; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
0
|
|
|
|
|
|
die "The $class class must implement the step method"; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |