line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PITA::XML::Test; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
PITA::XML::Test - The result of an single executed test script |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
The C class provides data objects that represent the |
12
|
|
|
|
|
|
|
output from a single test script. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 METHODS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
10
|
|
|
10
|
|
51
|
use strict; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
300
|
|
19
|
10
|
|
|
10
|
|
49
|
use Carp (); |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
200
|
|
20
|
10
|
|
|
10
|
|
50
|
use Params::Util qw{ _STRING _SCALAR0 }; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
538
|
|
21
|
|
|
|
|
|
|
|
22
|
10
|
|
|
10
|
|
69
|
use vars qw{$VERSION}; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
1377
|
|
23
|
|
|
|
|
|
|
BEGIN { |
24
|
10
|
|
|
10
|
|
5547
|
$VERSION = '0.52'; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
##################################################################### |
32
|
|
|
|
|
|
|
# Constructor and Accessors |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=pod |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 new |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
The C constructor is used to create a new test result. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
TO BE COMPLETED |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Returns a C object, or dies on error. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub new { |
47
|
3
|
|
|
3
|
1
|
1040
|
my $class = shift; |
48
|
3
|
|
|
|
|
19
|
my $self = bless { @_ }, $class; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Check the object |
51
|
3
|
|
|
|
|
16
|
$self->_init; |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
7
|
$self; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _init { |
57
|
4
|
|
|
4
|
|
9
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Check the test name |
60
|
4
|
100
|
|
|
|
14
|
if ( $self->name ) { |
61
|
3
|
50
|
|
|
|
10
|
unless ( _STRING($self->name) ) { |
62
|
0
|
|
|
|
|
0
|
Carp::croak('Invalid or missing cmd'); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} else { |
65
|
1
|
|
|
|
|
3
|
$self->{name} = undef; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Check the mime-type |
69
|
4
|
|
100
|
|
|
25
|
$self->{language} ||= 'text/x-tap'; |
70
|
4
|
50
|
|
|
|
12
|
unless ( _STRING($self->language) ) { |
71
|
0
|
|
|
|
|
0
|
Carp::croak('Invalid or missing language mime-type'); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Check the STDOUT |
75
|
4
|
50
|
|
|
|
25
|
unless ( PITA::XML->_OUTPUT($self, 'stdout') ) { |
76
|
0
|
|
|
|
|
0
|
Carp::croak('Invalid or missing STDOUT output'); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Check the STDERR (optional) |
80
|
4
|
100
|
66
|
|
|
22
|
if ( defined $self->stderr or exists $self->{stderr} ) { |
81
|
3
|
50
|
|
|
|
14
|
unless ( PITA::XML->_OUTPUT($self, 'stderr') ) { |
82
|
0
|
|
|
|
|
0
|
Carp::croak('Invalid or missing STDERR output'); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} else { |
85
|
1
|
|
|
|
|
2
|
$self->{stderr} = undef; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Check the optional exit code |
89
|
4
|
100
|
|
|
|
15
|
if ( defined $self->exitcode ) { |
90
|
3
|
50
|
|
|
|
11
|
unless ( defined _STRING($self->exitcode) ) { |
91
|
0
|
|
|
|
|
0
|
Carp::croak('Invalid exit code'); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} else { |
94
|
1
|
|
|
|
|
3
|
$self->{exitcode} = undef; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
4
|
|
|
|
|
12
|
$self; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=pod |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 name |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
The C accessor returns the name of the test, if it has one. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns a not-null string, or C if the test is unnamed. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub name { |
111
|
11
|
|
|
11
|
1
|
1375
|
$_[0]->{name}; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=pod |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 language |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
The C accessor returns the mime-type of the test output. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
On creation, this defaults to "text/x-tap" unless otherwise specified. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub language { |
125
|
7
|
|
|
7
|
1
|
35
|
$_[0]->{language}; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=pod |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 stdout |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
The C accessor returns the output of the test as a |
133
|
|
|
|
|
|
|
C reference. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub stdout { |
138
|
7
|
|
|
7
|
1
|
47
|
$_[0]->{stdout}; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=pod |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 stderr |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
The C accessor returns the error output of the command |
146
|
|
|
|
|
|
|
as a C reference, or C if the test was run via a |
147
|
|
|
|
|
|
|
communications mechanism that does not support error output. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub stderr { |
152
|
11
|
|
|
11
|
1
|
58
|
$_[0]->{stderr}; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=pod |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 exitcode |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
The C accessor returns the process exit code of the test, |
160
|
|
|
|
|
|
|
if run across a communications mechanism that supports the concept |
161
|
|
|
|
|
|
|
of an exit code. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Returns a not-null string (generally an integer), or C if the |
164
|
|
|
|
|
|
|
test did not return an exit code. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub exitcode { |
169
|
11
|
|
|
11
|
1
|
51
|
$_[0]->{exitcode}; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=pod |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 SUPPORT |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Bugs should be reported via the CPAN bug tracker at |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
L |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
For other issues, contact the author. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 AUTHOR |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Adam Kennedy Eadamk@cpan.orgE, L |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 SEE ALSO |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
L |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
The Perl Image-based Testing Architecture (L) |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 COPYRIGHT |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Copyright 2005 - 2013 Adam Kennedy. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This program is free software; you can redistribute |
200
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
The full text of the license can be found in the |
203
|
|
|
|
|
|
|
LICENSE file included with this module. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=cut |