|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Test::Stream::Event::Plan;  | 
| 
2
 | 
107
 | 
 
 | 
 
 | 
  
107
  
 | 
 
 | 
711
 | 
 use strict;  | 
| 
 
 | 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
133
 | 
    | 
| 
 
 | 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2423
 | 
    | 
| 
3
 | 
107
 | 
 
 | 
 
 | 
  
107
  
 | 
 
 | 
314
 | 
 use warnings;  | 
| 
 
 | 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
103
 | 
    | 
| 
 
 | 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2188
 | 
    | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
5
 | 
107
 | 
 
 | 
 
 | 
  
107
  
 | 
 
 | 
413
 | 
 use base 'Test::Stream::Event';  | 
| 
 
 | 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
110
 | 
    | 
| 
 
 | 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6609
 | 
    | 
| 
6
 | 
107
 | 
 
 | 
 
 | 
  
107
  
 | 
 
 | 
840
 | 
 use Test::Stream::HashBase accessors => [qw/max directive reason/];  | 
| 
 
 | 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
143
 | 
    | 
| 
 
 | 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
665
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
107
 | 
 
 | 
 
 | 
  
107
  
 | 
 
 | 
446
 | 
 use Test::Stream::Formatter::TAP qw/OUT_STD/;  | 
| 
 
 | 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
120
 | 
    | 
| 
 
 | 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
511
 | 
    | 
| 
9
 | 
107
 | 
 
 | 
 
 | 
  
107
  
 | 
 
 | 
417
 | 
 use Carp qw/confess/;  | 
| 
 
 | 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
135
 | 
    | 
| 
 
 | 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
41707
 | 
    | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 my %ALLOWED = (  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     'SKIP'    => 1,  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     'NO PLAN' => 1,  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 );  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub init {  | 
| 
17
 | 
356
 | 
 
 | 
 
 | 
  
356
  
 | 
  
0
  
 | 
1533
 | 
     $_[0]->SUPER::init();  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
19
 | 
356
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
766
 | 
     if ($_[0]->{+DIRECTIVE}) {  | 
| 
20
 | 
20
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
65
 | 
         $_[0]->{+DIRECTIVE} = 'SKIP'    if $_[0]->{+DIRECTIVE} eq 'skip_all';  | 
| 
21
 | 
20
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
58
 | 
         $_[0]->{+DIRECTIVE} = 'NO PLAN' if $_[0]->{+DIRECTIVE} eq 'no_plan';  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         confess "'" . $_[0]->{+DIRECTIVE} . "' is not a valid plan directive"  | 
| 
24
 | 
20
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
262
 | 
             unless $ALLOWED{$_[0]->{+DIRECTIVE}};  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     else {  | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         confess "Cannot have a reason without a directive!"  | 
| 
28
 | 
336
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
849
 | 
             if defined $_[0]->{+REASON};  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         confess "No number of tests specified"  | 
| 
31
 | 
335
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
1109
 | 
             unless defined $_[0]->{+MAX};  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         confess "Plan test count '" . $_[0]->{+MAX}  . "' does not appear to be a valid positive integer"  | 
| 
34
 | 
334
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
1799
 | 
             unless $_[0]->{+MAX} =~ m/^\d+$/;  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
36
 | 
333
 | 
 
 | 
 
 | 
 
 | 
 
 | 
831
 | 
         $_[0]->{+DIRECTIVE} = '';  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub to_tap {  | 
| 
41
 | 
299
 | 
 
 | 
 
 | 
  
299
  
 | 
  
1
  
 | 
364
 | 
     my $self = shift;  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
43
 | 
299
 | 
 
 | 
 
 | 
 
 | 
 
 | 
408
 | 
     my $max       = $self->{+MAX};  | 
| 
44
 | 
299
 | 
 
 | 
 
 | 
 
 | 
 
 | 
610
 | 
     my $directive = $self->{+DIRECTIVE};  | 
| 
45
 | 
299
 | 
 
 | 
 
 | 
 
 | 
 
 | 
334
 | 
     my $reason    = $self->{+REASON};  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
47
 | 
299
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
777
 | 
     return if $directive && $directive eq 'NO PLAN';  | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
49
 | 
297
 | 
 
 | 
 
 | 
 
 | 
 
 | 
450
 | 
     my $plan = "1..$max";  | 
| 
50
 | 
297
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
589
 | 
     if ($directive) {  | 
| 
51
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
         $plan .= " # $directive";  | 
| 
52
 | 
5
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
16
 | 
         $plan .= " $reason" if defined $reason;  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
55
 | 
297
 | 
 
 | 
 
 | 
 
 | 
 
 | 
880
 | 
     return [OUT_STD, "$plan\n"];  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub update_state {  | 
| 
59
 | 
351
 | 
 
 | 
 
 | 
  
351
  
 | 
  
1
  
 | 
380
 | 
     my $self = shift;  | 
| 
60
 | 
351
 | 
 
 | 
 
 | 
 
 | 
 
 | 
389
 | 
     my ($state) = @_;  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
62
 | 
351
 | 
 
 | 
  
 66
  
 | 
 
 | 
 
 | 
1508
 | 
     $state->plan($self->{+DIRECTIVE} || $self->{+MAX});  | 
| 
63
 | 
351
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1499
 | 
     $state->set_skip_reason($self->{+REASON});  | 
| 
64
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
66
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub terminate {  | 
| 
67
 | 
350
 | 
 
 | 
 
 | 
  
350
  
 | 
  
1
  
 | 
454
 | 
     my $self = shift;  | 
| 
68
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     # On skip_all we want to terminate the hub  | 
| 
69
 | 
350
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
1039
 | 
     return 0 if $self->{+DIRECTIVE} && $self->{+DIRECTIVE} eq 'SKIP';  | 
| 
70
 | 
333
 | 
 
 | 
 
 | 
 
 | 
 
 | 
564
 | 
     return undef;  | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub global {  | 
| 
74
 | 
335
 | 
 
 | 
 
 | 
  
335
  
 | 
  
1
  
 | 
355
 | 
     my $self = shift;  | 
| 
75
 | 
335
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
1204
 | 
     return 0 unless $self->{+DIRECTIVE};  | 
| 
76
 | 
17
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
55
 | 
     return 0 unless $self->{+DIRECTIVE} eq 'SKIP';  | 
| 
77
 | 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
46
 | 
     return 1;  | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |