line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
18
|
|
|
18
|
|
26532
|
package Test::Output; |
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
928
|
|
3
|
|
|
|
|
|
|
use vars qw($VERSION); |
4
|
18
|
|
|
18
|
|
95
|
|
|
18
|
|
|
|
|
34
|
|
|
18
|
|
|
|
|
451
|
|
5
|
18
|
|
|
18
|
|
90
|
use warnings; |
|
18
|
|
|
|
|
47
|
|
|
18
|
|
|
|
|
514
|
|
6
|
|
|
|
|
|
|
use strict; |
7
|
18
|
|
|
18
|
|
90
|
|
|
18
|
|
|
|
|
43
|
|
|
18
|
|
|
|
|
144
|
|
8
|
18
|
|
|
18
|
|
31116
|
use Test::Builder; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Test::Output::Tie; |
10
|
|
|
|
|
|
|
use Sub::Exporter -setup => { |
11
|
|
|
|
|
|
|
exports => [ |
12
|
|
|
|
|
|
|
qw(output_is output_isnt output_like output_unlike |
13
|
|
|
|
|
|
|
stderr_is stderr_isnt stderr_like stderr_unlike |
14
|
|
|
|
|
|
|
stdout_is stdout_isnt stdout_like stdout_unlike |
15
|
|
|
|
|
|
|
combined_is combined_isnt combined_like combined_unlike |
16
|
|
|
|
|
|
|
output_from stderr_from stdout_from combined_from |
17
|
|
|
|
|
|
|
) |
18
|
|
|
|
|
|
|
], |
19
|
|
|
|
|
|
|
groups => { |
20
|
|
|
|
|
|
|
stdout => [ |
21
|
|
|
|
|
|
|
qw( |
22
|
|
|
|
|
|
|
stdout_is stdout_isnt stdout_like stdout_unlike |
23
|
|
|
|
|
|
|
) |
24
|
|
|
|
|
|
|
], |
25
|
|
|
|
|
|
|
stderr => [ |
26
|
|
|
|
|
|
|
qw( |
27
|
|
|
|
|
|
|
stderr_is stderr_isnt stderr_like stderr_unlike |
28
|
|
|
|
|
|
|
) |
29
|
|
|
|
|
|
|
], |
30
|
|
|
|
|
|
|
output => [ |
31
|
|
|
|
|
|
|
qw( |
32
|
|
|
|
|
|
|
output_is output_isnt output_like output_unlike |
33
|
|
|
|
|
|
|
) |
34
|
|
|
|
|
|
|
], |
35
|
|
|
|
|
|
|
combined => [ |
36
|
|
|
|
|
|
|
qw( |
37
|
|
|
|
|
|
|
combined_is combined_isnt combined_like combined_unlike |
38
|
|
|
|
|
|
|
) |
39
|
|
|
|
|
|
|
], |
40
|
|
|
|
|
|
|
functions => [ |
41
|
|
|
|
|
|
|
qw( |
42
|
|
|
|
|
|
|
output_from stderr_from stdout_from combined_from |
43
|
|
|
|
|
|
|
) |
44
|
|
|
|
|
|
|
], |
45
|
|
|
|
|
|
|
tests => [ |
46
|
|
|
|
|
|
|
qw( |
47
|
|
|
|
|
|
|
output_is output_isnt output_like output_unlike |
48
|
|
|
|
|
|
|
stderr_is stderr_isnt stderr_like stderr_unlike |
49
|
|
|
|
|
|
|
stdout_is stdout_isnt stdout_like stdout_unlike |
50
|
|
|
|
|
|
|
combined_is combined_isnt combined_like combined_unlike |
51
|
|
|
|
|
|
|
) |
52
|
|
|
|
|
|
|
], |
53
|
|
|
|
|
|
|
default => [ '-tests' ], |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $Test = Test::Builder->new; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#line 66 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$VERSION = '0.16'; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#line 116 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#line 120 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#line 140 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub stdout_is (&$;$$) { |
70
|
|
|
|
|
|
|
my $test = shift; |
71
|
|
|
|
|
|
|
my $expected = shift; |
72
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
73
|
|
|
|
|
|
|
my $description = shift; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $stdout = stdout_from($test); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $ok = ( $stdout eq $expected ); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) |
80
|
|
|
|
|
|
|
|| $Test->diag("STDOUT is:\n$stdout\nnot:\n$expected\nas expected"); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
return $ok; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub stdout_isnt (&$;$$) { |
86
|
|
|
|
|
|
|
my $test = shift; |
87
|
|
|
|
|
|
|
my $expected = shift; |
88
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
89
|
|
|
|
|
|
|
my $description = shift; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my $stdout = stdout_from($test); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $ok = ( $stdout ne $expected ); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) |
96
|
|
|
|
|
|
|
|| $Test->diag("STDOUT:\n$stdout\nmatching:\n$expected\nnot expected"); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
return $ok; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
#line 190 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub stdout_like (&$;$$) { |
104
|
|
|
|
|
|
|
my $test = shift; |
105
|
|
|
|
|
|
|
my $expected = shift; |
106
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
107
|
|
|
|
|
|
|
my $description = shift; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
unless ( my $regextest = _chkregex( 'stdout_like' => $expected ) ) { |
110
|
|
|
|
|
|
|
return $regextest; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my $stdout = stdout_from($test); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $ok = ( $stdout =~ $expected ); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) |
118
|
|
|
|
|
|
|
|| $Test->diag("STDOUT:\n$stdout\ndoesn't match:\n$expected\nas expected"); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
return $ok; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub stdout_unlike (&$;$$) { |
124
|
|
|
|
|
|
|
my $test = shift; |
125
|
|
|
|
|
|
|
my $expected = shift; |
126
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
127
|
|
|
|
|
|
|
my $description = shift; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
unless ( my $regextest = _chkregex( 'stdout_unlike' => $expected ) ) { |
130
|
|
|
|
|
|
|
return $regextest; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
my $stdout = stdout_from($test); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my $ok = ( $stdout !~ $expected ); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) |
138
|
|
|
|
|
|
|
|| $Test->diag("STDOUT:\n$stdout\nmatches:\n$expected\nnot expected"); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
return $ok; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
#line 250 |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub stderr_is (&$;$$) { |
146
|
|
|
|
|
|
|
my $test = shift; |
147
|
|
|
|
|
|
|
my $expected = shift; |
148
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
149
|
|
|
|
|
|
|
my $description = shift; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
my $stderr = stderr_from($test); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
my $ok = ( $stderr eq $expected ); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) |
156
|
|
|
|
|
|
|
|| $Test->diag("STDERR is:\n$stderr\nnot:\n$expected\nas expected"); |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
return $ok; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub stderr_isnt (&$;$$) { |
162
|
|
|
|
|
|
|
my $test = shift; |
163
|
|
|
|
|
|
|
my $expected = shift; |
164
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
165
|
|
|
|
|
|
|
my $description = shift; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
my $stderr = stderr_from($test); |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
my $ok = ( $stderr ne $expected ); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) |
172
|
|
|
|
|
|
|
|| $Test->diag("STDERR:\n$stderr\nmatches:\n$expected\nnot expected"); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
return $ok; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
#line 301 |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub stderr_like (&$;$$) { |
180
|
|
|
|
|
|
|
my $test = shift; |
181
|
|
|
|
|
|
|
my $expected = shift; |
182
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
183
|
|
|
|
|
|
|
my $description = shift; |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
unless ( my $regextest = _chkregex( 'stderr_like' => $expected ) ) { |
186
|
|
|
|
|
|
|
return $regextest; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
my $stderr = stderr_from($test); |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
my $ok = ( $stderr =~ $expected ); |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) |
194
|
|
|
|
|
|
|
|| $Test->diag("STDERR:\n$stderr\ndoesn't match:\n$expected\nas expected"); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
return $ok; |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub stderr_unlike (&$;$$) { |
200
|
|
|
|
|
|
|
my $test = shift; |
201
|
|
|
|
|
|
|
my $expected = shift; |
202
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
203
|
|
|
|
|
|
|
my $description = shift; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
unless ( my $regextest = _chkregex( 'stderr_unlike' => $expected ) ) { |
206
|
|
|
|
|
|
|
return $regextest; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
my $stderr = stderr_from($test); |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
my $ok = ( $stderr !~ $expected ); |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) |
214
|
|
|
|
|
|
|
|| $Test->diag("STDERR:\n$stderr\nmatches:\n$expected\nnot expected"); |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
return $ok; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
#line 363 |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub combined_is (&$;$$) { |
222
|
|
|
|
|
|
|
my $test = shift; |
223
|
|
|
|
|
|
|
my $expected = shift; |
224
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
225
|
|
|
|
|
|
|
my $description = shift; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
my $combined = combined_from($test); |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
my $ok = ( $combined eq $expected ); |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) |
232
|
|
|
|
|
|
|
|| $Test->diag( |
233
|
|
|
|
|
|
|
"STDOUT & STDERR are:\n$combined\nnot:\n$expected\nas expected"); |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
return $ok; |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
sub combined_isnt (&$;$$) { |
239
|
|
|
|
|
|
|
my $test = shift; |
240
|
|
|
|
|
|
|
my $expected = shift; |
241
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
242
|
|
|
|
|
|
|
my $description = shift; |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
my $combined = combined_from($test); |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
my $ok = ( $combined ne $expected ); |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) |
249
|
|
|
|
|
|
|
|| $Test->diag( |
250
|
|
|
|
|
|
|
"STDOUT & STDERR:\n$combined\nmatching:\n$expected\nnot expected"); |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
return $ok; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
#line 417 |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub combined_like (&$;$$) { |
258
|
|
|
|
|
|
|
my $test = shift; |
259
|
|
|
|
|
|
|
my $expected = shift; |
260
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
261
|
|
|
|
|
|
|
my $description = shift; |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
unless ( my $regextest = _chkregex( 'combined_like' => $expected ) ) { |
264
|
|
|
|
|
|
|
return $regextest; |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
my $combined = combined_from($test); |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
my $ok = ( $combined =~ $expected ); |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) |
272
|
|
|
|
|
|
|
|| $Test->diag( |
273
|
|
|
|
|
|
|
"STDOUT & STDERR:\n$combined\ndon't match:\n$expected\nas expected"); |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
return $ok; |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
sub combined_unlike (&$;$$) { |
279
|
|
|
|
|
|
|
my $test = shift; |
280
|
|
|
|
|
|
|
my $expected = shift; |
281
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
282
|
|
|
|
|
|
|
my $description = shift; |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
unless ( my $regextest = _chkregex( 'combined_unlike' => $expected ) ) { |
285
|
|
|
|
|
|
|
return $regextest; |
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
my $combined = combined_from($test); |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
my $ok = ( $combined !~ $expected ); |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) |
293
|
|
|
|
|
|
|
|| $Test->diag( |
294
|
|
|
|
|
|
|
"STDOUT & STDERR:\n$combined\nmatching:\n$expected\nnot expected"); |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
return $ok; |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
#line 516 |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
sub output_is (&$$;$$) { |
302
|
|
|
|
|
|
|
my $test = shift; |
303
|
|
|
|
|
|
|
my $expout = shift; |
304
|
|
|
|
|
|
|
my $experr = shift; |
305
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
306
|
|
|
|
|
|
|
my $description = shift; |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
my ( $stdout, $stderr ) = output_from($test); |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
my $ok = 1; |
311
|
|
|
|
|
|
|
my $diag; |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
if ( defined($experr) && defined($expout) ) { |
314
|
|
|
|
|
|
|
unless ( $stdout eq $expout ) { |
315
|
|
|
|
|
|
|
$ok = 0; |
316
|
|
|
|
|
|
|
$diag .= "STDOUT is:\n$stdout\nnot:\n$expout\nas expected"; |
317
|
|
|
|
|
|
|
} |
318
|
|
|
|
|
|
|
unless ( $stderr eq $experr ) { |
319
|
|
|
|
|
|
|
$diag .= "\n" unless ($ok); |
320
|
|
|
|
|
|
|
$ok = 0; |
321
|
|
|
|
|
|
|
$diag .= "STDERR is:\n$stderr\nnot:\n$experr\nas expected"; |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
elsif ( defined($expout) ) { |
325
|
|
|
|
|
|
|
$ok = ( $stdout eq $expout ); |
326
|
|
|
|
|
|
|
$diag .= "STDOUT is:\n$stdout\nnot:\n$expout\nas expected"; |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
elsif ( defined($experr) ) { |
329
|
|
|
|
|
|
|
$ok = ( $stderr eq $experr ); |
330
|
|
|
|
|
|
|
$diag .= "STDERR is:\n$stderr\nnot:\n$experr\nas expected"; |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
else { |
333
|
|
|
|
|
|
|
unless ( $stdout eq '' ) { |
334
|
|
|
|
|
|
|
$ok = 0; |
335
|
|
|
|
|
|
|
$diag .= "STDOUT is:\n$stdout\nnot:\n\nas expected"; |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
unless ( $stderr eq '' ) { |
338
|
|
|
|
|
|
|
$diag .= "\n" unless ($ok); |
339
|
|
|
|
|
|
|
$ok = 0; |
340
|
|
|
|
|
|
|
$diag .= "STDERR is:\n$stderr\nnot:\n\nas expected"; |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
} |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) || $Test->diag($diag); |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
return $ok; |
347
|
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
sub output_isnt (&$$;$$) { |
350
|
|
|
|
|
|
|
my $test = shift; |
351
|
|
|
|
|
|
|
my $expout = shift; |
352
|
|
|
|
|
|
|
my $experr = shift; |
353
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
354
|
|
|
|
|
|
|
my $description = shift; |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
my ( $stdout, $stderr ) = output_from($test); |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
my $ok = 1; |
359
|
|
|
|
|
|
|
my $diag; |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
if ( defined($experr) && defined($expout) ) { |
362
|
|
|
|
|
|
|
if ( $stdout eq $expout ) { |
363
|
|
|
|
|
|
|
$ok = 0; |
364
|
|
|
|
|
|
|
$diag .= "STDOUT:\n$stdout\nmatching:\n$expout\nnot expected"; |
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
if ( $stderr eq $experr ) { |
367
|
|
|
|
|
|
|
$diag .= "\n" unless ($ok); |
368
|
|
|
|
|
|
|
$ok = 0; |
369
|
|
|
|
|
|
|
$diag .= "STDERR:\n$stderr\nmatching:\n$experr\nnot expected"; |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
} |
372
|
|
|
|
|
|
|
elsif ( defined($expout) ) { |
373
|
|
|
|
|
|
|
$ok = ( $stdout ne $expout ); |
374
|
|
|
|
|
|
|
$diag = "STDOUT:\n$stdout\nmatching:\n$expout\nnot expected"; |
375
|
|
|
|
|
|
|
} |
376
|
|
|
|
|
|
|
elsif ( defined($experr) ) { |
377
|
|
|
|
|
|
|
$ok = ( $stderr ne $experr ); |
378
|
|
|
|
|
|
|
$diag = "STDERR:\n$stderr\nmatching:\n$experr\nnot expected"; |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
else { |
381
|
|
|
|
|
|
|
if ( $stdout eq '' ) { |
382
|
|
|
|
|
|
|
$ok = 0; |
383
|
|
|
|
|
|
|
$diag = "STDOUT:\n$stdout\nmatching:\n\nnot expected"; |
384
|
|
|
|
|
|
|
} |
385
|
|
|
|
|
|
|
if ( $stderr eq '' ) { |
386
|
|
|
|
|
|
|
$diag .= "\n" unless ($ok); |
387
|
|
|
|
|
|
|
$ok = 0; |
388
|
|
|
|
|
|
|
$diag .= "STDERR:\n$stderr\nmatching:\n\nnot expected"; |
389
|
|
|
|
|
|
|
} |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) || $Test->diag($diag); |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
return $ok; |
395
|
|
|
|
|
|
|
} |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
#line 647 |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
sub output_like (&$$;$$) { |
400
|
|
|
|
|
|
|
my $test = shift; |
401
|
|
|
|
|
|
|
my $expout = shift; |
402
|
|
|
|
|
|
|
my $experr = shift; |
403
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
404
|
|
|
|
|
|
|
my $description = shift; |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
my ( $stdout, $stderr ) = output_from($test); |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
my $ok = 1; |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
unless ( |
411
|
|
|
|
|
|
|
my $regextest = _chkregex( |
412
|
|
|
|
|
|
|
'output_like_STDERR' => $experr, |
413
|
|
|
|
|
|
|
'output_like_STDOUT' => $expout |
414
|
|
|
|
|
|
|
) |
415
|
|
|
|
|
|
|
) |
416
|
|
|
|
|
|
|
{ |
417
|
|
|
|
|
|
|
return $regextest; |
418
|
|
|
|
|
|
|
} |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
my $diag; |
421
|
|
|
|
|
|
|
if ( defined($experr) && defined($expout) ) { |
422
|
|
|
|
|
|
|
unless ( $stdout =~ $expout ) { |
423
|
|
|
|
|
|
|
$ok = 0; |
424
|
|
|
|
|
|
|
$diag .= "STDOUT:\n$stdout\ndoesn't match:\n$expout\nas expected"; |
425
|
|
|
|
|
|
|
} |
426
|
|
|
|
|
|
|
unless ( $stderr =~ $experr ) { |
427
|
|
|
|
|
|
|
$diag .= "\n" unless ($ok); |
428
|
|
|
|
|
|
|
$ok = 0; |
429
|
|
|
|
|
|
|
$diag .= "STDERR:\n$stderr\ndoesn't match:\n$experr\nas expected"; |
430
|
|
|
|
|
|
|
} |
431
|
|
|
|
|
|
|
} |
432
|
|
|
|
|
|
|
elsif ( defined($expout) ) { |
433
|
|
|
|
|
|
|
$ok = ( $stdout =~ $expout ); |
434
|
|
|
|
|
|
|
$diag .= "STDOUT:\n$stdout\ndoesn't match:\n$expout\nas expected"; |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
elsif ( defined($experr) ) { |
437
|
|
|
|
|
|
|
$ok = ( $stderr =~ $experr ); |
438
|
|
|
|
|
|
|
$diag .= "STDERR:\n$stderr\ndoesn't match:\n$experr\nas expected"; |
439
|
|
|
|
|
|
|
} |
440
|
|
|
|
|
|
|
else { |
441
|
|
|
|
|
|
|
unless ( $stdout eq '' ) { |
442
|
|
|
|
|
|
|
$ok = 0; |
443
|
|
|
|
|
|
|
$diag .= "STDOUT is:\n$stdout\nnot:\n\nas expected"; |
444
|
|
|
|
|
|
|
} |
445
|
|
|
|
|
|
|
unless ( $stderr eq '' ) { |
446
|
|
|
|
|
|
|
$diag .= "\n" unless ($ok); |
447
|
|
|
|
|
|
|
$ok = 0; |
448
|
|
|
|
|
|
|
$diag .= "STDERR is:\n$stderr\nnot:\n\nas expected"; |
449
|
|
|
|
|
|
|
} |
450
|
|
|
|
|
|
|
} |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) || $Test->diag($diag); |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
return $ok; |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
sub output_unlike (&$$;$$) { |
458
|
|
|
|
|
|
|
my $test = shift; |
459
|
|
|
|
|
|
|
my $expout = shift; |
460
|
|
|
|
|
|
|
my $experr = shift; |
461
|
|
|
|
|
|
|
my $options = shift if ( ref( $_[0] ) ); |
462
|
|
|
|
|
|
|
my $description = shift; |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
my ( $stdout, $stderr ) = output_from($test); |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
my $ok = 1; |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
unless ( |
469
|
|
|
|
|
|
|
my $regextest = _chkregex( |
470
|
|
|
|
|
|
|
'output_unlike_STDERR' => $experr, |
471
|
|
|
|
|
|
|
'output_unlike_STDOUT' => $expout |
472
|
|
|
|
|
|
|
) |
473
|
|
|
|
|
|
|
) |
474
|
|
|
|
|
|
|
{ |
475
|
|
|
|
|
|
|
return $regextest; |
476
|
|
|
|
|
|
|
} |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
my $diag; |
479
|
|
|
|
|
|
|
if ( defined($experr) && defined($expout) ) { |
480
|
|
|
|
|
|
|
if ( $stdout =~ $expout ) { |
481
|
|
|
|
|
|
|
$ok = 0; |
482
|
|
|
|
|
|
|
$diag .= "STDOUT:\n$stdout\nmatches:\n$expout\nnot expected"; |
483
|
|
|
|
|
|
|
} |
484
|
|
|
|
|
|
|
if ( $stderr =~ $experr ) { |
485
|
|
|
|
|
|
|
$diag .= "\n" unless ($ok); |
486
|
|
|
|
|
|
|
$ok = 0; |
487
|
|
|
|
|
|
|
$diag .= "STDERR:\n$stderr\nmatches:\n$experr\nnot expected"; |
488
|
|
|
|
|
|
|
} |
489
|
|
|
|
|
|
|
} |
490
|
|
|
|
|
|
|
elsif ( defined($expout) ) { |
491
|
|
|
|
|
|
|
$ok = ( $stdout !~ $expout ); |
492
|
|
|
|
|
|
|
$diag .= "STDOUT:\n$stdout\nmatches:\n$expout\nnot expected"; |
493
|
|
|
|
|
|
|
} |
494
|
|
|
|
|
|
|
elsif ( defined($experr) ) { |
495
|
|
|
|
|
|
|
$ok = ( $stderr !~ $experr ); |
496
|
|
|
|
|
|
|
$diag .= "STDERR:\n$stderr\nmatches:\n$experr\nnot expected"; |
497
|
|
|
|
|
|
|
} |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
$Test->ok( $ok, $description ) || $Test->diag($diag); |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
return $ok; |
502
|
|
|
|
|
|
|
} |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
#line 804 |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
#line 808 |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
#line 817 |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
sub stdout_from (&) { |
511
|
|
|
|
|
|
|
my $test = shift; |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
select( ( select(STDOUT), $| = 1 )[0] ); |
514
|
|
|
|
|
|
|
my $out = tie *STDOUT, 'Test::Output::Tie'; |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
&$test; |
517
|
|
|
|
|
|
|
my $stdout = $out->read; |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
undef $out; |
520
|
|
|
|
|
|
|
untie *STDOUT; |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
return $stdout; |
523
|
|
|
|
|
|
|
} |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
#line 841 |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
sub stderr_from (&) { |
528
|
|
|
|
|
|
|
my $test = shift; |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
local $SIG{__WARN__} = sub { print STDERR @_ } |
531
|
|
|
|
|
|
|
if $] < 5.008; |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
select( ( select(STDERR), $| = 1 )[0] ); |
534
|
|
|
|
|
|
|
my $err = tie *STDERR, 'Test::Output::Tie'; |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
&$test; |
537
|
|
|
|
|
|
|
my $stderr = $err->read; |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
undef $err; |
540
|
|
|
|
|
|
|
untie *STDERR; |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
return $stderr; |
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
#line 868 |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
sub output_from (&) { |
548
|
|
|
|
|
|
|
my $test = shift; |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
select( ( select(STDOUT), $| = 1 )[0] ); |
551
|
|
|
|
|
|
|
select( ( select(STDERR), $| = 1 )[0] ); |
552
|
|
|
|
|
|
|
my $out = tie *STDOUT, 'Test::Output::Tie'; |
553
|
|
|
|
|
|
|
my $err = tie *STDERR, 'Test::Output::Tie'; |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
&$test; |
556
|
|
|
|
|
|
|
my $stdout = $out->read; |
557
|
|
|
|
|
|
|
my $stderr = $err->read; |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
undef $out; |
560
|
|
|
|
|
|
|
undef $err; |
561
|
|
|
|
|
|
|
untie *STDOUT; |
562
|
|
|
|
|
|
|
untie *STDERR; |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
return ( $stdout, $stderr ); |
565
|
|
|
|
|
|
|
} |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
#line 898 |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
sub combined_from (&) { |
570
|
|
|
|
|
|
|
my $test = shift; |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
select( ( select(STDOUT), $| = 1 )[0] ); |
573
|
|
|
|
|
|
|
select( ( select(STDERR), $| = 1 )[0] ); |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
open( STDERR, ">&STDOUT" ); |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
my $out = tie *STDOUT, 'Test::Output::Tie'; |
578
|
|
|
|
|
|
|
tie *STDERR, 'Test::Output::Tie', $out; |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
&$test; |
581
|
|
|
|
|
|
|
my $combined = $out->read; |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
undef $out; |
584
|
|
|
|
|
|
|
{ |
585
|
|
|
|
|
|
|
no warnings; |
586
|
|
|
|
|
|
|
untie *STDOUT; |
587
|
|
|
|
|
|
|
untie *STDERR; |
588
|
|
|
|
|
|
|
} |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
return ($combined); |
591
|
|
|
|
|
|
|
} |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
sub _chkregex { |
594
|
|
|
|
|
|
|
my %regexs = @_; |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
foreach my $test ( keys(%regexs) ) { |
597
|
|
|
|
|
|
|
next unless ( defined( $regexs{$test} ) ); |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
my $usable_regex = $Test->maybe_regex( $regexs{$test} ); |
600
|
|
|
|
|
|
|
unless ( defined($usable_regex) ) { |
601
|
|
|
|
|
|
|
my $ok = $Test->ok( 0, $test ); |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
$Test->diag("'$regexs{$test}' doesn't look much like a regex to me."); |
604
|
|
|
|
|
|
|
# unless $ok; |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
return $ok; |
607
|
|
|
|
|
|
|
} |
608
|
|
|
|
|
|
|
} |
609
|
|
|
|
|
|
|
return 1; |
610
|
|
|
|
|
|
|
} |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
#line 980 |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
1; # End of Test::Output |