line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: DefaultReport.pm,v 1.10 2003/03/02 11:52:09 m_ilya Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTTP::WebTest::Plugin::DefaultReport; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
HTTP::WebTest::Plugin::DefaultReport - Default test report plugin. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Not Applicable |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This plugin is the default test report plugin. It builds a simple text |
16
|
|
|
|
|
|
|
report. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
10
|
|
|
10
|
|
62
|
use strict; |
|
10
|
|
|
|
|
77
|
|
|
10
|
|
|
|
|
365
|
|
21
|
|
|
|
|
|
|
|
22
|
10
|
|
|
10
|
|
52
|
use base qw(HTTP::WebTest::ReportPlugin); |
|
10
|
|
|
|
|
25
|
|
|
10
|
|
|
|
|
7797
|
|
23
|
10
|
|
|
10
|
|
86
|
use HTTP::WebTest::Utils qw(make_access_method); |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
1485745
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 TEST PARAMETERS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=for pod_merge copy params |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 default_report |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
I |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
This parameter controls whether the default report plugin is used for |
34
|
|
|
|
|
|
|
test report creation. Value C means that default report plugin |
35
|
|
|
|
|
|
|
will be used, value C means that it will not. |
36
|
|
|
|
|
|
|
It can also be used to disable all output |
37
|
|
|
|
|
|
|
(i.e. if this parameter has value C and no other report plugins |
38
|
|
|
|
|
|
|
are loaded). |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head3 Allowed values |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
C, C |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head3 Default value |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
C |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 test_name |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Name associated with this URL in the test report and error messages. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 show_headers |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Include request and response headers in the test report. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head3 Allowed values |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
C, C |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head3 Default value |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
C |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 show_html |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Include content of HTTP response in the test report. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head3 Allowed values |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
C, C |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head3 Default value |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
C |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 show_cookies |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Option to display any cookies sent or received. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head3 Allowed values |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
C, C |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head3 Default value |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
C |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 terse |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Option to display shorter test report. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=over 4 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * summary |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Only a one-line summary for each URL |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item * failed_only |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Only tests that failed and the summary |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * no |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Show all tests and the summary |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head3 Default value |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
C |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=back |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub param_types { |
115
|
1007
|
|
|
1007
|
1
|
5029
|
return shift->SUPER::param_types . "\n" . |
116
|
|
|
|
|
|
|
q(default_report yesno |
117
|
|
|
|
|
|
|
test_name scalar |
118
|
|
|
|
|
|
|
show_html yesno |
119
|
|
|
|
|
|
|
show_cookies yesno |
120
|
|
|
|
|
|
|
show_headers yesno |
121
|
|
|
|
|
|
|
terse scalar('^(?:no|summary|failed_only)$') ); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# accessor for temporary buffer |
125
|
|
|
|
|
|
|
*tempout_ref = make_access_method('TEMPOUT_REF', sub { my $s = ''; \$s } ); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub start_tests { |
128
|
82
|
|
|
82
|
1
|
250
|
my $self = shift; |
129
|
|
|
|
|
|
|
|
130
|
82
|
|
|
|
|
505
|
$self->global_validate_params(qw(default_report)); |
131
|
|
|
|
|
|
|
|
132
|
82
|
100
|
|
|
|
579
|
return unless $self->global_yesno_test_param('default_report', 1); |
133
|
|
|
|
|
|
|
|
134
|
68
|
|
|
|
|
385
|
$self->SUPER::start_tests; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# reset temporary output storage |
137
|
68
|
|
|
|
|
279
|
$self->tempout_ref(undef); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub report_test { |
141
|
190
|
|
|
190
|
0
|
411
|
my $self = shift; |
142
|
|
|
|
|
|
|
|
143
|
190
|
|
|
|
|
823
|
$self->global_validate_params(qw(default_report)); |
144
|
|
|
|
|
|
|
|
145
|
190
|
100
|
|
|
|
913
|
return unless $self->global_yesno_test_param('default_report', 1); |
146
|
|
|
|
|
|
|
|
147
|
171
|
|
|
|
|
852
|
$self->validate_params(qw(test_name show_html show_headers |
148
|
|
|
|
|
|
|
show_cookies terse)); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# get test params we handle |
151
|
171
|
|
|
|
|
841
|
my $test_name = $self->test_param('test_name', 'N/A'); |
152
|
171
|
|
|
|
|
825
|
my $show_html = $self->yesno_test_param('show_html'); |
153
|
171
|
|
|
|
|
762
|
my $show_cookies = $self->yesno_test_param('show_cookies'); |
154
|
171
|
|
|
|
|
592
|
my $show_headers = $self->yesno_test_param('show_headers'); |
155
|
171
|
|
|
|
|
746
|
my $terse = lc $self->test_param('terse', 'no'); |
156
|
|
|
|
|
|
|
|
157
|
171
|
|
|
|
|
370
|
my $url = 'N/A'; |
158
|
171
|
50
|
|
|
|
744
|
if($self->webtest->current_request) { |
159
|
171
|
|
|
|
|
658
|
$url = $self->webtest->current_request->uri; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
171
|
100
|
|
|
|
1765
|
return if $terse eq 'summary'; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
# output buffer |
165
|
167
|
|
|
|
|
346
|
my $out = ''; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# test header |
168
|
167
|
|
|
|
|
451
|
$out .= "Test Name: $test_name\n"; |
169
|
167
|
|
|
|
|
1455
|
$out .= "URL: $url\n\n"; |
170
|
|
|
|
|
|
|
|
171
|
167
|
|
|
|
|
1254
|
my $not_ok_num = 0; |
172
|
|
|
|
|
|
|
|
173
|
167
|
|
|
|
|
291
|
for my $result (@{$self->webtest->current_results}) { |
|
167
|
|
|
|
|
696
|
|
174
|
|
|
|
|
|
|
# test results |
175
|
278
|
|
|
|
|
630
|
my $group_comment = $$result[0]; |
176
|
|
|
|
|
|
|
|
177
|
278
|
|
|
|
|
1301
|
my @results = @$result[1 .. @$result - 1]; |
178
|
278
|
|
|
|
|
1609
|
my @not_ok_results = grep +(not $_->ok), @results; |
179
|
278
|
|
|
|
|
574
|
$not_ok_num += @not_ok_results; |
180
|
|
|
|
|
|
|
|
181
|
278
|
100
|
|
|
|
767
|
if($terse eq 'failed_only') { |
182
|
|
|
|
|
|
|
# skip all positive results in output |
183
|
5
|
|
|
|
|
10
|
@results = @not_ok_results; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
278
|
100
|
|
|
|
707
|
next unless @results; |
187
|
|
|
|
|
|
|
|
188
|
274
|
|
|
|
|
1525
|
$out .= $self->sformat(<
|
189
|
|
|
|
|
|
|
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
190
|
|
|
|
|
|
|
FORMAT |
191
|
|
|
|
|
|
|
|
192
|
274
|
|
|
|
|
1054
|
for my $subresult (@$result[1 .. @$result - 1]) { |
193
|
342
|
|
|
|
|
1285
|
my $comment = $subresult->comment; |
194
|
342
|
100
|
|
|
|
1171
|
my $ok = $subresult->ok ? 'SUCCEED' : 'FAIL'; |
195
|
|
|
|
|
|
|
|
196
|
342
|
|
|
|
|
1285
|
$out .= $self->sformat(<
|
197
|
|
|
|
|
|
|
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<< |
198
|
|
|
|
|
|
|
FORMAT |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
# true if show_*** parameters should take effect |
203
|
167
|
100
|
|
|
|
647
|
my $show_xxx = $terse eq 'failed_only' ? $not_ok_num > 0 : 1; |
204
|
|
|
|
|
|
|
|
205
|
167
|
|
|
|
|
574
|
my $response = $self->webtest->current_response; |
206
|
167
|
|
|
|
|
663
|
my $request = $self->webtest->current_request; |
207
|
|
|
|
|
|
|
|
208
|
167
|
100
|
100
|
|
|
606
|
if($show_headers and $show_xxx) { |
209
|
|
|
|
|
|
|
# show all headers |
210
|
|
|
|
|
|
|
|
211
|
3
|
|
|
|
|
7
|
$out .= "\n"; |
212
|
|
|
|
|
|
|
|
213
|
3
|
|
|
|
|
9
|
$out .= " REQUEST HEADERS:\n"; |
214
|
3
|
|
|
|
|
20
|
$out .= $request->method . ' ' . $request->uri . "\n"; |
215
|
3
|
|
|
|
|
42
|
$out .= $request->headers_as_string . "\n"; |
216
|
3
|
|
|
|
|
411
|
$out .= " RESPONSE HEADERS:\n"; |
217
|
3
|
|
|
|
|
22
|
$out .= $response->protocol . " " . $response->status_line . "\n"; |
218
|
3
|
|
|
|
|
82
|
$out .= $response->headers_as_string . "\n"; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
167
|
100
|
66
|
|
|
1278
|
if($show_cookies and $show_xxx) { |
222
|
|
|
|
|
|
|
# show sent and recieved cookies |
223
|
|
|
|
|
|
|
|
224
|
3
|
|
|
|
|
18
|
my @sent = $request->header('Cookie'); |
225
|
3
|
|
|
|
|
263
|
my @recv = $response->header('Set-Cookie'); |
226
|
|
|
|
|
|
|
|
227
|
3
|
|
|
|
|
121
|
$out .= "\n"; |
228
|
|
|
|
|
|
|
|
229
|
3
|
|
|
|
|
6
|
$out .= " SENT COOKIE(S)\n"; |
230
|
3
|
|
|
|
|
8
|
for my $cookie (@sent) { |
231
|
2
|
|
|
|
|
11
|
$out .= " $cookie\n"; |
232
|
|
|
|
|
|
|
} |
233
|
3
|
100
|
|
|
|
13
|
unless(@sent) { |
234
|
1
|
|
|
|
|
2
|
$out .= " *** none ***\n"; |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
3
|
|
|
|
|
7
|
$out .= " RECEIVED COOKIE(S)\n"; |
238
|
3
|
|
|
|
|
6
|
for my $cookie (@recv) { |
239
|
3
|
|
|
|
|
11
|
$out .= " $cookie\n"; |
240
|
|
|
|
|
|
|
} |
241
|
3
|
50
|
|
|
|
15
|
unless(@recv) { |
242
|
0
|
|
|
|
|
0
|
$out .= " *** none ***\n"; |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
|
246
|
167
|
100
|
100
|
|
|
640
|
if($show_html and $show_xxx) { |
247
|
|
|
|
|
|
|
# content in response |
248
|
|
|
|
|
|
|
|
249
|
4
|
|
|
|
|
10
|
$out .= "\n"; |
250
|
|
|
|
|
|
|
|
251
|
4
|
|
|
|
|
9
|
$out .= " PAGE CONTENT:\n"; |
252
|
4
|
|
|
|
|
24
|
$out .= $response->content . "\n"; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
167
|
|
|
|
|
398
|
$out .= "\n\n"; |
256
|
|
|
|
|
|
|
|
257
|
167
|
|
|
|
|
247
|
${$self->tempout_ref} .= $out; |
|
167
|
|
|
|
|
645
|
|
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
sub end_tests { |
261
|
78
|
|
|
78
|
1
|
387
|
my $self = shift; |
262
|
|
|
|
|
|
|
|
263
|
78
|
|
|
|
|
295
|
$self->global_validate_params(qw(default_report)); |
264
|
|
|
|
|
|
|
|
265
|
78
|
100
|
|
|
|
334
|
return unless $self->global_yesno_test_param('default_report', 1); |
266
|
|
|
|
|
|
|
|
267
|
64
|
|
|
|
|
858
|
$self->print("Failed Succeeded Test Name\n"); |
268
|
|
|
|
|
|
|
|
269
|
64
|
|
|
|
|
127
|
my $total_fail_num = 0; |
270
|
64
|
|
|
|
|
111
|
my $total_suc_num = 0; |
271
|
|
|
|
|
|
|
|
272
|
64
|
|
|
|
|
113
|
for my $test (@{$self->webtest->tests}) { |
|
64
|
|
|
|
|
232
|
|
273
|
166
|
|
|
|
|
600
|
my $results = $test->results; |
274
|
|
|
|
|
|
|
|
275
|
166
|
|
|
|
|
272
|
my $fail_num = 0; |
276
|
166
|
|
|
|
|
243
|
my $suc_num = 0; |
277
|
166
|
|
|
|
|
627
|
for my $result (@$results) { |
278
|
274
|
|
|
|
|
857
|
for my $subresult (@$result[1 .. @$result - 1]) { |
279
|
341
|
100
|
|
|
|
1114
|
if($subresult) { |
280
|
275
|
|
|
|
|
2317
|
$suc_num ++; |
281
|
|
|
|
|
|
|
} else { |
282
|
66
|
|
|
|
|
374
|
$fail_num ++; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
166
|
|
|
|
|
278
|
$total_fail_num += $fail_num; |
288
|
166
|
|
|
|
|
213
|
$total_suc_num += $suc_num; |
289
|
|
|
|
|
|
|
|
290
|
166
|
|
100
|
|
|
738
|
my $name = $test->param('test_name') || '*** no name ***'; |
291
|
166
|
|
|
|
|
576
|
$self->fprint(<
|
292
|
|
|
|
|
|
|
@||||| @||||| @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
293
|
|
|
|
|
|
|
FORMAT |
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
|
296
|
64
|
|
|
|
|
289
|
$self->print("\n\n"); |
297
|
|
|
|
|
|
|
|
298
|
64
|
|
|
|
|
124
|
$self->print(${$self->tempout_ref}); |
|
64
|
|
|
|
|
236
|
|
299
|
|
|
|
|
|
|
|
300
|
64
|
|
|
|
|
450
|
$self->print("Total web tests failed: $total_fail_num ", |
301
|
|
|
|
|
|
|
" succeeded: $total_suc_num\n"); |
302
|
|
|
|
|
|
|
|
303
|
64
|
|
|
|
|
482
|
$self->SUPER::end_tests; |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
# formated output |
307
|
|
|
|
|
|
|
sub sformat { |
308
|
782
|
|
|
782
|
0
|
1090
|
my $self = shift; |
309
|
782
|
|
|
|
|
996
|
my $format = shift; |
310
|
782
|
|
|
|
|
3916
|
local $^A = ''; |
311
|
782
|
|
|
|
|
4243
|
formline($format, @_); |
312
|
782
|
|
|
|
|
5957
|
return $^A; |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
# print line using format specification |
316
|
|
|
|
|
|
|
sub fprint { |
317
|
166
|
|
|
166
|
0
|
248
|
my $self = shift; |
318
|
166
|
|
|
|
|
249
|
my $format = shift; |
319
|
166
|
|
|
|
|
575
|
$self->print($self->sformat($format, @_)); |
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=head1 COPYRIGHT |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
Copyright (c) 2000-2001 Richard Anderson. All rights reserved. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
Copyright (c) 2001-2003 Ilya Martynov. All rights reserved. |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
329
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
=head1 SEE ALSO |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
L |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
L |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
L |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
L |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=cut |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
1; |