line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Event::Ok; |
2
|
107
|
|
|
107
|
|
1138
|
use strict; |
|
107
|
|
|
|
|
188
|
|
|
107
|
|
|
|
|
2856
|
|
3
|
107
|
|
|
107
|
|
585
|
use warnings; |
|
107
|
|
|
|
|
182
|
|
|
107
|
|
|
|
|
3334
|
|
4
|
|
|
|
|
|
|
|
5
|
107
|
|
|
107
|
|
536
|
use Scalar::Util qw/blessed/; |
|
107
|
|
|
|
|
194
|
|
|
107
|
|
|
|
|
5364
|
|
6
|
107
|
|
|
107
|
|
591
|
use Carp qw/confess/; |
|
107
|
|
|
|
|
195
|
|
|
107
|
|
|
|
|
5149
|
|
7
|
|
|
|
|
|
|
|
8
|
107
|
|
|
107
|
|
58085
|
use Test::Stream::Formatter::TAP qw/OUT_STD OUT_TODO OUT_ERR/; |
|
107
|
|
|
|
|
249
|
|
|
107
|
|
|
|
|
434
|
|
9
|
|
|
|
|
|
|
|
10
|
107
|
|
|
107
|
|
58796
|
use Test::Stream::Event::Diag; |
|
107
|
|
|
|
|
302
|
|
|
107
|
|
|
|
|
926
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Test::Stream::Event( |
13
|
107
|
|
|
|
|
563
|
accessors => [qw/pass effective_pass name diag allow_bad_name/], |
14
|
107
|
|
|
107
|
|
650
|
); |
|
107
|
|
|
|
|
197
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
3220
|
|
|
3220
|
0
|
4769
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
3220
|
100
|
|
|
|
9235
|
confess("No debug info provided!") unless $self->{+DEBUG}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Do not store objects here, only true or false |
22
|
3219
|
100
|
|
|
|
7833
|
$self->{+PASS} = $self->{+PASS} ? 1 : 0; |
23
|
|
|
|
|
|
|
|
24
|
3219
|
|
100
|
|
|
11547
|
$self->{+EFFECTIVE_PASS} = $self->{+PASS} || $self->{+DEBUG}->no_fail || 0; |
25
|
|
|
|
|
|
|
|
26
|
3219
|
100
|
|
|
|
7993
|
return if $self->{+ALLOW_BAD_NAME}; |
27
|
3218
|
|
100
|
|
|
8097
|
my $name = $self->{+NAME} || return; |
28
|
3141
|
100
|
100
|
|
|
21618
|
return unless index($name, '#') != -1 || index($name, "\n") != -1; |
29
|
2
|
|
|
|
|
11
|
$self->debug->throw("'$name' is not a valid name, names must not contain '#' or newlines.") |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub to_tap { |
33
|
2934
|
|
|
2934
|
1
|
4347
|
my $self = shift; |
34
|
2934
|
|
|
|
|
4121
|
my ($num) = @_; |
35
|
|
|
|
|
|
|
|
36
|
2934
|
|
|
|
|
5444
|
my $name = $self->{+NAME}; |
37
|
2934
|
|
|
|
|
4159
|
my $debug = $self->{+DEBUG}; |
38
|
2934
|
|
|
|
|
4758
|
my $skip = $debug->{skip}; |
39
|
2934
|
|
|
|
|
4092
|
my $todo = $debug->{todo}; |
40
|
|
|
|
|
|
|
|
41
|
2934
|
|
|
|
|
4009
|
my $out = ""; |
42
|
2934
|
100
|
|
|
|
7218
|
$out .= "not " unless $self->{+PASS}; |
43
|
2934
|
|
|
|
|
3964
|
$out .= "ok"; |
44
|
2934
|
100
|
|
|
|
7840
|
$out .= " $num" if defined $num; |
45
|
2934
|
100
|
|
|
|
7674
|
$out .= " - $name" if $name; |
46
|
|
|
|
|
|
|
|
47
|
2934
|
100
|
100
|
|
|
12709
|
if (defined $skip && defined $todo) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
48
|
4
|
|
|
|
|
7
|
$out .= " # TODO & SKIP"; |
49
|
4
|
100
|
|
|
|
11
|
$out .= " $todo" if length $todo; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif (defined $todo) { |
52
|
10
|
|
|
|
|
28
|
$out .= " # TODO"; |
53
|
10
|
100
|
|
|
|
38
|
$out .= " $todo" if length $todo; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
elsif (defined $skip) { |
56
|
7
|
|
|
|
|
13
|
$out .= " # skip"; |
57
|
7
|
100
|
|
|
|
27
|
$out .= " $skip" if length $skip; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
2934
|
|
|
|
|
9385
|
my @out = [OUT_STD, "$out\n"]; |
61
|
|
|
|
|
|
|
|
62
|
2934
|
100
|
100
|
|
|
8633
|
if ($self->{+DIAG} && @{$self->{+DIAG}}) { |
|
21
|
|
|
|
|
99
|
|
63
|
19
|
100
|
|
|
|
69
|
my $diag_handle = $debug->no_diag ? OUT_TODO : OUT_ERR; |
64
|
|
|
|
|
|
|
|
65
|
19
|
|
|
|
|
30
|
for my $diag (@{$self->{+DIAG}}) { |
|
19
|
|
|
|
|
55
|
|
66
|
28
|
|
|
|
|
62
|
chomp(my $msg = $diag); |
67
|
|
|
|
|
|
|
|
68
|
28
|
100
|
|
|
|
113
|
$msg = "# $msg" unless $msg =~ m/^\n/; |
69
|
28
|
|
|
|
|
84
|
$msg =~ s/\n/\n# /g; |
70
|
28
|
|
|
|
|
131
|
push @out => [$diag_handle, "$msg\n"]; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
2934
|
|
|
|
|
9643
|
return @out; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub default_diag { |
78
|
199
|
|
|
199
|
1
|
301
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
199
|
100
|
|
|
|
524
|
return if $self->{+PASS}; |
81
|
|
|
|
|
|
|
|
82
|
198
|
|
|
|
|
330
|
my $name = $self->{+NAME}; |
83
|
198
|
|
|
|
|
308
|
my $dbg = $self->{+DEBUG}; |
84
|
198
|
|
|
|
|
329
|
my $pass = $self->{+PASS}; |
85
|
198
|
|
|
|
|
698
|
my $todo = defined $dbg->todo; |
86
|
|
|
|
|
|
|
|
87
|
198
|
100
|
|
|
|
940
|
my $msg = $todo ? "Failed (TODO)" : "Failed"; |
88
|
198
|
100
|
100
|
|
|
1085
|
my $prefix = $ENV{HARNESS_ACTIVE} && !$ENV{HARNESS_IS_VERBOSE} ? "\n" : ""; |
89
|
|
|
|
|
|
|
|
90
|
198
|
|
|
|
|
678
|
my $trace = $dbg->trace; |
91
|
|
|
|
|
|
|
|
92
|
198
|
100
|
|
|
|
488
|
if (defined $name) { |
93
|
157
|
|
|
|
|
499
|
$msg = qq[$prefix$msg test '$name'\n$trace.]; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
else { |
96
|
41
|
|
|
|
|
110
|
$msg = qq[$prefix$msg test $trace.]; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
198
|
|
|
|
|
817
|
return $msg; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
3185
|
|
|
3185
|
1
|
11187
|
sub update_state { $_[1]->bump($_[0]->{+EFFECTIVE_PASS}) } |
103
|
|
|
|
|
|
|
|
104
|
1765
|
|
|
1765
|
1
|
10988
|
sub causes_fail { !$_[0]->{+EFFECTIVE_PASS} } |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |