line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Event::Plan; |
2
|
107
|
|
|
107
|
|
1065
|
use strict; |
|
107
|
|
|
|
|
187
|
|
|
107
|
|
|
|
|
2815
|
|
3
|
107
|
|
|
107
|
|
512
|
use warnings; |
|
107
|
|
|
|
|
193
|
|
|
107
|
|
|
|
|
3509
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Test::Stream::Event( |
6
|
107
|
|
|
|
|
772
|
accessors => [qw/max directive reason/], |
7
|
107
|
|
|
107
|
|
542
|
); |
|
107
|
|
|
|
|
195
|
|
8
|
|
|
|
|
|
|
|
9
|
107
|
|
|
107
|
|
600
|
use Test::Stream::Formatter::TAP qw/OUT_STD/; |
|
107
|
|
|
|
|
198
|
|
|
107
|
|
|
|
|
802
|
|
10
|
107
|
|
|
107
|
|
588
|
use Carp qw/confess/; |
|
107
|
|
|
|
|
209
|
|
|
107
|
|
|
|
|
62034
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %ALLOWED = ( |
13
|
|
|
|
|
|
|
'SKIP' => 1, |
14
|
|
|
|
|
|
|
'NO PLAN' => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
355
|
|
|
355
|
0
|
2002
|
$_[0]->SUPER::init(); |
19
|
|
|
|
|
|
|
|
20
|
355
|
100
|
|
|
|
1096
|
if ($_[0]->{+DIRECTIVE}) { |
21
|
20
|
100
|
|
|
|
98
|
$_[0]->{+DIRECTIVE} = 'SKIP' if $_[0]->{+DIRECTIVE} eq 'skip_all'; |
22
|
20
|
100
|
|
|
|
90
|
$_[0]->{+DIRECTIVE} = 'NO PLAN' if $_[0]->{+DIRECTIVE} eq 'no_plan'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
confess "'" . $_[0]->{+DIRECTIVE} . "' is not a valid plan directive" |
25
|
20
|
100
|
|
|
|
316
|
unless $ALLOWED{$_[0]->{+DIRECTIVE}}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
|
|
|
|
|
|
confess "Cannot have a reason without a directive!" |
29
|
335
|
100
|
|
|
|
1393
|
if defined $_[0]->{+REASON}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
confess "No number of tests specified" |
32
|
334
|
100
|
|
|
|
1227
|
unless defined $_[0]->{+MAX}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
confess "Plan test count '" . $_[0]->{+MAX} . "' does not appear to be a valid positive integer" |
35
|
333
|
100
|
|
|
|
2232
|
unless $_[0]->{+MAX} =~ m/^\d+$/; |
36
|
|
|
|
|
|
|
|
37
|
332
|
|
|
|
|
1256
|
$_[0]->{+DIRECTIVE} = ''; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub to_tap { |
42
|
298
|
|
|
298
|
1
|
568
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
298
|
|
|
|
|
622
|
my $max = $self->{+MAX}; |
45
|
298
|
|
|
|
|
586
|
my $directive = $self->{+DIRECTIVE}; |
46
|
298
|
|
|
|
|
618
|
my $reason = $self->{+REASON}; |
47
|
|
|
|
|
|
|
|
48
|
298
|
100
|
100
|
|
|
1113
|
return if $directive && $directive eq 'NO PLAN'; |
49
|
|
|
|
|
|
|
|
50
|
296
|
|
|
|
|
634
|
my $plan = "1..$max"; |
51
|
296
|
100
|
|
|
|
949
|
if ($directive) { |
52
|
5
|
|
|
|
|
12
|
$plan .= " # $directive"; |
53
|
5
|
100
|
|
|
|
24
|
$plan .= " $reason" if defined $reason; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
296
|
|
|
|
|
1296
|
return [OUT_STD, "$plan\n"]; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub update_state { |
60
|
350
|
|
|
350
|
1
|
680
|
my $self = shift; |
61
|
350
|
|
|
|
|
603
|
my ($state) = @_; |
62
|
|
|
|
|
|
|
|
63
|
350
|
|
66
|
|
|
2127
|
$state->plan($self->{+DIRECTIVE} || $self->{+MAX}); |
64
|
350
|
|
|
|
|
1800
|
$state->set_skip_reason($self->{+REASON}); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub terminate { |
68
|
349
|
|
|
349
|
1
|
663
|
my $self = shift; |
69
|
|
|
|
|
|
|
# On skip_all we want to terminate the hub |
70
|
349
|
100
|
100
|
|
|
1796
|
return 0 if $self->{+DIRECTIVE} && $self->{+DIRECTIVE} eq 'SKIP'; |
71
|
332
|
|
|
|
|
851
|
return undef; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub global { |
75
|
334
|
|
|
334
|
1
|
991
|
my $self = shift; |
76
|
334
|
100
|
|
|
|
1741
|
return 0 unless $self->{+DIRECTIVE}; |
77
|
17
|
100
|
|
|
|
111
|
return 0 unless $self->{+DIRECTIVE} eq 'SKIP'; |
78
|
16
|
|
|
|
|
69
|
return 1; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |