line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TAP::Convert::TET; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
49993
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
68
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
63
|
|
5
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
182
|
|
6
|
2
|
|
|
2
|
|
2485
|
use TAP::Parser; |
|
2
|
|
|
|
|
165233
|
|
|
2
|
|
|
|
|
78
|
|
7
|
2
|
|
|
2
|
|
24
|
use Scalar::Util qw/blessed/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
232
|
|
8
|
2
|
|
|
2
|
|
10
|
use POSIX qw/strftime uname/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
18
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
4370
|
use version; our $VERSION = qv( '0.2.1' ); |
|
2
|
|
|
|
|
4866
|
|
|
2
|
|
|
|
|
13
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
185
|
use constant TCC_VERSION => '3.7a'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
127
|
|
13
|
2
|
|
|
2
|
|
9
|
use constant TIME_FORMAT => '%H:%M:%S'; # 20:09:33 |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
77
|
|
14
|
2
|
|
|
2
|
|
21
|
use constant DATETIME_FORMAT => '%H:%M:%S %Y%m%d'; # 20:09:33 19961128 |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
230
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %RESULT_TYPE = ( |
17
|
|
|
|
|
|
|
0 => "PASS", |
18
|
|
|
|
|
|
|
1 => "FAIL", |
19
|
|
|
|
|
|
|
2 => "UNRESOLVED", |
20
|
|
|
|
|
|
|
3 => "NOTINUSE", |
21
|
|
|
|
|
|
|
4 => "UNSUPPORTED", |
22
|
|
|
|
|
|
|
5 => "UNTESTED", |
23
|
|
|
|
|
|
|
6 => "UNINITIATED", |
24
|
|
|
|
|
|
|
7 => "NORESULT", |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
BEGIN { |
28
|
2
|
|
|
2
|
|
6
|
for my $attr ( |
29
|
|
|
|
|
|
|
qw(writer tcc_version time_format datetime_format program |
30
|
|
|
|
|
|
|
sequence) |
31
|
|
|
|
|
|
|
) { |
32
|
2
|
|
|
2
|
|
9
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
147
|
|
33
|
|
|
|
|
|
|
*$attr = sub { |
34
|
62
|
|
|
62
|
|
71
|
my $self = shift; |
35
|
62
|
100
|
|
|
|
783
|
return $self->{$attr} unless @_; |
36
|
12
|
|
|
|
|
24
|
$self->{$attr} = shift; |
37
|
12
|
|
|
|
|
21
|
return; |
38
|
12
|
|
|
|
|
1882
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
2
|
|
|
2
|
1
|
2473
|
my $class = shift; |
44
|
2
|
|
|
|
|
8
|
my $self = bless {}, $class; |
45
|
2
|
|
|
|
|
9
|
$self->_initialize( @_ ); |
46
|
2
|
|
|
|
|
30
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _initialize { |
50
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
51
|
2
|
|
50
|
|
|
7
|
my $args = shift || {}; |
52
|
|
|
|
|
|
|
|
53
|
2
|
50
|
|
|
|
8
|
croak "The only argument to new must be a hash reference" |
54
|
|
|
|
|
|
|
unless 'HASH' eq ref $args; |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
50
|
|
|
16
|
$self->writer( |
57
|
|
|
|
|
|
|
$self->_writer_for_output( delete $args->{output} || \*STDOUT ) ); |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
50
|
|
|
14
|
$self->tcc_version( delete $args->{tcc_version} || TCC_VERSION ); |
60
|
2
|
|
50
|
|
|
12
|
$self->time_format( delete $args->{time_format} || TIME_FORMAT ); |
61
|
2
|
|
50
|
|
|
21
|
$self->datetime_format( delete $args->{datetime_format} |
62
|
|
|
|
|
|
|
|| DATETIME_FORMAT ); |
63
|
2
|
|
50
|
|
|
58
|
$self->program( delete $args->{program} || __PACKAGE__ ); |
64
|
2
|
|
|
|
|
6
|
$self->sequence( 1 ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
2
|
|
6
|
sub _next_sequence { shift->{sequence}++ } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Return a closure that outputs to the specified reference. Handles |
70
|
|
|
|
|
|
|
# filehandles, objects that can print, array references, scalar |
71
|
|
|
|
|
|
|
# references |
72
|
|
|
|
|
|
|
sub _writer_for_output { |
73
|
2
|
|
|
2
|
|
5
|
my ( $self, $output ) = @_; |
74
|
|
|
|
|
|
|
|
75
|
2
|
50
|
|
|
|
7
|
if ( my $ref = ref $output ) { |
76
|
2
|
50
|
33
|
|
|
22
|
if ( $ref eq 'GLOB' |
|
|
50
|
33
|
|
|
|
|
|
|
0
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|| ( blessed $output && $output->can( 'print' ) ) ) { |
78
|
0
|
|
|
0
|
|
0
|
return sub { $output->print( @_, "\n" ) }; |
|
0
|
|
|
|
|
0
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
elsif ( $ref eq 'ARRAY' ) { |
81
|
2
|
|
|
40
|
|
15
|
return sub { push @$output, @_ }; |
|
40
|
|
|
|
|
138
|
|
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
elsif ( $ref eq 'SCALAR' ) { |
84
|
0
|
|
|
0
|
|
0
|
return sub { $$output .= $_[0] . "\n" }; |
|
0
|
|
|
|
|
0
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
else { |
87
|
0
|
|
|
|
|
0
|
croak "Don't know how to write to a $ref"; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
else { |
91
|
0
|
|
|
|
|
0
|
croak "output must be a reference to an array, scalar or filehandle"; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
0
|
return; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub write { |
98
|
40
|
|
|
40
|
1
|
49
|
my $self = shift; |
99
|
40
|
|
|
|
|
88
|
$self->writer->( join( '', @_ ) ); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub tet { |
103
|
40
|
|
|
40
|
1
|
137
|
my $self = shift; |
104
|
40
|
50
|
|
|
|
84
|
croak "TET lines have three parts" |
105
|
|
|
|
|
|
|
unless @_ == 3; |
106
|
40
|
|
|
|
|
126
|
$self->write( join( '|', @_ ) ); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub _timestamp { |
110
|
4
|
|
|
4
|
|
7
|
my $self = shift; |
111
|
4
|
|
|
|
|
11
|
return strftime( $self->time_format, localtime ); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub start { |
115
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
116
|
|
|
|
|
|
|
|
117
|
2
|
|
50
|
|
|
7
|
$self->tet( |
118
|
|
|
|
|
|
|
0, |
119
|
|
|
|
|
|
|
join( ' ', |
120
|
|
|
|
|
|
|
$self->tcc_version, strftime( $self->datetime_format, localtime ) ), |
121
|
|
|
|
|
|
|
"User: " |
122
|
|
|
|
|
|
|
. ( $ENV{USER} || 'unknown' ) |
123
|
|
|
|
|
|
|
. " ($<) " |
124
|
|
|
|
|
|
|
. $self->program |
125
|
|
|
|
|
|
|
. " Start" |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
|
128
|
2
|
|
|
|
|
22
|
$self->tet( 5, join( ' ', uname ), 'System Information' ); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub end { |
132
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
133
|
2
|
|
|
|
|
7
|
$self->tet( 900, $self->_timestamp, 'TCC End' ); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub convert { |
137
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
138
|
2
|
|
|
|
|
3
|
my $parser = shift; |
139
|
|
|
|
|
|
|
|
140
|
2
|
|
|
|
|
5
|
my $seq = $self->_next_sequence; |
141
|
2
|
|
33
|
|
|
9
|
my $name = shift || "unnamed test $seq"; |
142
|
2
|
|
|
|
|
9
|
my $time = $self->_timestamp; |
143
|
|
|
|
|
|
|
|
144
|
2
|
|
|
|
|
12
|
$self->tet( 10, "$seq $name $time", 'TC Start' ); |
145
|
|
|
|
|
|
|
|
146
|
2
|
|
|
|
|
11
|
while ( my $result = $parser->next ) { |
147
|
11
|
100
|
|
|
|
4058
|
if ( $result->is_test ) { |
148
|
6
|
|
|
|
|
41
|
my $test_number = $result->number; |
149
|
|
|
|
|
|
|
|
150
|
6
|
|
|
|
|
33
|
$self->tet( 400, "$seq $test_number 1 $time", 'IC Start' ); |
151
|
6
|
|
|
|
|
23
|
$self->tet( 200, "$seq $test_number $time", 'TP Start' ); |
152
|
6
|
|
|
|
|
26
|
$self->tet( 520, "$seq $test_number 000000000 1 1", |
153
|
|
|
|
|
|
|
$result->as_string ); |
154
|
|
|
|
|
|
|
|
155
|
6
|
100
|
|
|
|
30
|
my $rc = |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
156
|
|
|
|
|
|
|
$result->has_skip ? 3 |
157
|
|
|
|
|
|
|
: $result->has_todo ? 5 |
158
|
|
|
|
|
|
|
: $result->is_ok ? 0 |
159
|
|
|
|
|
|
|
: 1; |
160
|
|
|
|
|
|
|
|
161
|
6
|
|
50
|
|
|
221
|
$self->tet( |
162
|
|
|
|
|
|
|
220, |
163
|
|
|
|
|
|
|
"$seq $test_number $rc $time", |
164
|
|
|
|
|
|
|
$RESULT_TYPE{$rc} || 'UNKNOWN' |
165
|
|
|
|
|
|
|
); |
166
|
|
|
|
|
|
|
|
167
|
6
|
|
|
|
|
32
|
$self->tet( 410, "$seq $test_number 1 $time", 'IC End' ); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
else { |
170
|
|
|
|
|
|
|
# Ignore everything else for now |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
2
|
|
|
|
|
481
|
$self->tet( 80, "$seq 0 $time", 'TC End' ); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |
178
|
|
|
|
|
|
|
__END__ |