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