line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Event::Plan; |
2
|
107
|
|
|
107
|
|
1078
|
use strict; |
|
107
|
|
|
|
|
201
|
|
|
107
|
|
|
|
|
2913
|
|
3
|
107
|
|
|
107
|
|
580
|
use warnings; |
|
107
|
|
|
|
|
184
|
|
|
107
|
|
|
|
|
3534
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Test::Stream::Event( |
6
|
107
|
|
|
|
|
804
|
accessors => [qw/max directive reason/], |
7
|
107
|
|
|
107
|
|
534
|
); |
|
107
|
|
|
|
|
195
|
|
8
|
|
|
|
|
|
|
|
9
|
107
|
|
|
107
|
|
604
|
use Test::Stream::Formatter::TAP qw/OUT_STD/; |
|
107
|
|
|
|
|
195
|
|
|
107
|
|
|
|
|
733
|
|
10
|
107
|
|
|
107
|
|
560
|
use Carp qw/confess/; |
|
107
|
|
|
|
|
194
|
|
|
107
|
|
|
|
|
62496
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %ALLOWED = ( |
13
|
|
|
|
|
|
|
'SKIP' => 1, |
14
|
|
|
|
|
|
|
'NO PLAN' => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
355
|
|
|
355
|
0
|
2012
|
$_[0]->SUPER::init(); |
19
|
|
|
|
|
|
|
|
20
|
355
|
100
|
|
|
|
1134
|
if ($_[0]->{+DIRECTIVE}) { |
21
|
20
|
100
|
|
|
|
88
|
$_[0]->{+DIRECTIVE} = 'SKIP' if $_[0]->{+DIRECTIVE} eq 'skip_all'; |
22
|
20
|
100
|
|
|
|
75
|
$_[0]->{+DIRECTIVE} = 'NO PLAN' if $_[0]->{+DIRECTIVE} eq 'no_plan'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
confess "'" . $_[0]->{+DIRECTIVE} . "' is not a valid plan directive" |
25
|
20
|
100
|
|
|
|
304
|
unless $ALLOWED{$_[0]->{+DIRECTIVE}}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
|
|
|
|
|
|
confess "Cannot have a reason without a directive!" |
29
|
335
|
100
|
|
|
|
1276
|
if defined $_[0]->{+REASON}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
confess "No number of tests specified" |
32
|
334
|
100
|
|
|
|
1209
|
unless defined $_[0]->{+MAX}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
confess "Plan test count '" . $_[0]->{+MAX} . "' does not appear to be a valid positive integer" |
35
|
333
|
100
|
|
|
|
2261
|
unless $_[0]->{+MAX} =~ m/^\d+$/; |
36
|
|
|
|
|
|
|
|
37
|
332
|
|
|
|
|
1259
|
$_[0]->{+DIRECTIVE} = ''; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub to_tap { |
42
|
298
|
|
|
298
|
1
|
553
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
298
|
|
|
|
|
643
|
my $max = $self->{+MAX}; |
45
|
298
|
|
|
|
|
593
|
my $directive = $self->{+DIRECTIVE}; |
46
|
298
|
|
|
|
|
577
|
my $reason = $self->{+REASON}; |
47
|
|
|
|
|
|
|
|
48
|
298
|
100
|
100
|
|
|
1148
|
return if $directive && $directive eq 'NO PLAN'; |
49
|
|
|
|
|
|
|
|
50
|
296
|
|
|
|
|
669
|
my $plan = "1..$max"; |
51
|
296
|
100
|
|
|
|
884
|
if ($directive) { |
52
|
5
|
|
|
|
|
9
|
$plan .= " # $directive"; |
53
|
5
|
100
|
|
|
|
23
|
$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
|
655
|
my $self = shift; |
61
|
350
|
|
|
|
|
609
|
my ($state) = @_; |
62
|
|
|
|
|
|
|
|
63
|
350
|
|
66
|
|
|
2232
|
$state->plan($self->{+DIRECTIVE} || $self->{+MAX}); |
64
|
350
|
|
|
|
|
1912
|
$state->set_skip_reason($self->{+REASON}); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub terminate { |
68
|
349
|
|
|
349
|
1
|
670
|
my $self = shift; |
69
|
|
|
|
|
|
|
# On skip_all we want to terminate the hub |
70
|
349
|
100
|
100
|
|
|
1881
|
return 0 if $self->{+DIRECTIVE} && $self->{+DIRECTIVE} eq 'SKIP'; |
71
|
332
|
|
|
|
|
893
|
return undef; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub global { |
75
|
334
|
|
|
334
|
1
|
981
|
my $self = shift; |
76
|
334
|
100
|
|
|
|
1905
|
return 0 unless $self->{+DIRECTIVE}; |
77
|
17
|
100
|
|
|
|
64
|
return 0 unless $self->{+DIRECTIVE} eq 'SKIP'; |
78
|
16
|
|
|
|
|
61
|
return 1; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |