line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Mason::Tests; |
2
|
|
|
|
|
|
|
$HTML::Mason::Tests::VERSION = '1.58'; |
3
|
27
|
|
|
27
|
|
27619
|
use strict; |
|
27
|
|
|
|
|
203
|
|
|
27
|
|
|
|
|
728
|
|
4
|
27
|
|
|
27
|
|
135
|
use warnings; |
|
27
|
|
|
|
|
41
|
|
|
27
|
|
|
|
|
647
|
|
5
|
|
|
|
|
|
|
|
6
|
27
|
|
|
27
|
|
132
|
use Cwd; |
|
27
|
|
|
|
|
48
|
|
|
27
|
|
|
|
|
2244
|
|
7
|
|
|
|
|
|
|
|
8
|
27
|
|
|
27
|
|
162
|
use File::Path; |
|
27
|
|
|
|
|
54
|
|
|
27
|
|
|
|
|
1444
|
|
9
|
27
|
|
|
27
|
|
801
|
use File::Spec; |
|
27
|
|
|
|
|
63
|
|
|
27
|
|
|
|
|
556
|
|
10
|
|
|
|
|
|
|
|
11
|
27
|
|
|
27
|
|
7317
|
use HTML::Mason; |
|
27
|
|
|
|
|
101
|
|
|
27
|
|
|
|
|
1227
|
|
12
|
27
|
|
|
27
|
|
13155
|
use HTML::Mason::Compiler::ToObject; |
|
27
|
|
|
|
|
92
|
|
|
27
|
|
|
|
|
963
|
|
13
|
|
|
|
|
|
|
|
14
|
27
|
|
|
27
|
|
15282
|
use Getopt::Long; |
|
27
|
|
|
|
|
221801
|
|
|
27
|
|
|
|
|
129
|
|
15
|
|
|
|
|
|
|
|
16
|
27
|
|
|
27
|
|
16318
|
use Test::Builder (); |
|
27
|
|
|
|
|
1140430
|
|
|
27
|
|
|
|
|
930
|
|
17
|
|
|
|
|
|
|
|
18
|
27
|
|
|
27
|
|
256
|
use vars qw($VERBOSE $DEBUG @SHARED); |
|
27
|
|
|
|
|
57
|
|
|
27
|
|
|
|
|
85374
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $Test = Test::Builder->new; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$VERBOSE = $ENV{MASON_DEBUG} || $ENV{MASON_VERBOSE} || $ENV{TEST_VERBOSE}; |
23
|
|
|
|
|
|
|
$DEBUG = $ENV{MASON_DEBUG}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$| = 1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
@SHARED = ( { path => '/shared/check_error', |
28
|
|
|
|
|
|
|
component => <<'EOF', |
29
|
|
|
|
|
|
|
<% ($error) ? "Error: $error" : "No error!?" %> |
30
|
|
|
|
|
|
|
<%init> |
31
|
|
|
|
|
|
|
if ($error) { |
32
|
|
|
|
|
|
|
my @lines = split("\n",$error); |
33
|
|
|
|
|
|
|
$error = join("\n",@lines[0..$lines-1]); |
34
|
|
|
|
|
|
|
$error =~ s{\s+at .*}{}g; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
%init> |
37
|
|
|
|
|
|
|
<%args> |
38
|
|
|
|
|
|
|
$error |
39
|
|
|
|
|
|
|
$lines=>1 |
40
|
|
|
|
|
|
|
%args> |
41
|
|
|
|
|
|
|
EOF |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
{ path => '/shared/display_comp_obj', |
44
|
|
|
|
|
|
|
component => <<'EOF', |
45
|
|
|
|
|
|
|
Declared args: |
46
|
|
|
|
|
|
|
% my %decl = %{$comp->declared_args}; |
47
|
|
|
|
|
|
|
% foreach (sort keys %decl) { |
48
|
|
|
|
|
|
|
<% $_ %><% (defined($decl{$_}->{default})) ? "=>".$decl{$_}->{default} : "" %> |
49
|
|
|
|
|
|
|
% } |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
I am <% $comp->is_subcomp ? '' : 'not ' %>a subcomponent. |
52
|
|
|
|
|
|
|
I am <% $comp->is_method ? '' : 'not ' %>a method. |
53
|
|
|
|
|
|
|
I am <% $comp->is_file_based ? '' : 'not ' %>file-based. |
54
|
|
|
|
|
|
|
% if (defined($comp->name)) { |
55
|
|
|
|
|
|
|
My short name is <% $comp->name =~ /anon/ ? '[anon something]' : $comp->name %>. |
56
|
|
|
|
|
|
|
% } |
57
|
|
|
|
|
|
|
% if ($comp->is_subcomp and defined($comp->owner)) { |
58
|
|
|
|
|
|
|
My parent component is <% $comp->owner->title %>. |
59
|
|
|
|
|
|
|
% } |
60
|
|
|
|
|
|
|
% if (defined($comp->dir_path)) { |
61
|
|
|
|
|
|
|
My directory is <% $comp->dir_path %>. |
62
|
|
|
|
|
|
|
% } |
63
|
|
|
|
|
|
|
% my @subkeys = sort keys(%{$comp->subcomps}); |
64
|
|
|
|
|
|
|
I have <% scalar(@subkeys) %> subcomponent(s). |
65
|
|
|
|
|
|
|
% if (@subkeys) { |
66
|
|
|
|
|
|
|
Including one called <% $comp->subcomps($subkeys[0])->name %>. |
67
|
|
|
|
|
|
|
% } |
68
|
|
|
|
|
|
|
My title is <% $comp->title =~ /anon/ ? '[anon something]' : $comp->title %>. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
% if (defined($comp->path)) { |
71
|
|
|
|
|
|
|
My path is <% $comp->path %>. |
72
|
|
|
|
|
|
|
% } |
73
|
|
|
|
|
|
|
% if (defined($comp->comp_id)) { |
74
|
|
|
|
|
|
|
My comp_id is <% $comp->comp_id =~ /anon/ ? '[anon something]' : $comp->comp_id %>. |
75
|
|
|
|
|
|
|
% } |
76
|
|
|
|
|
|
|
<%args> |
77
|
|
|
|
|
|
|
$comp |
78
|
|
|
|
|
|
|
%args> |
79
|
|
|
|
|
|
|
EOF |
80
|
|
|
|
|
|
|
}, |
81
|
|
|
|
|
|
|
{ path => '/shared/display_req_obj', |
82
|
|
|
|
|
|
|
component => <<'EOF', |
83
|
|
|
|
|
|
|
My depth is <% $m->depth %>. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
I <% $m->is_subrequest ? 'am' : 'am not' %> a subrequest. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The top-level component is <% $m->request_comp->title %>. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
My stack looks like: |
90
|
|
|
|
|
|
|
----- |
91
|
|
|
|
|
|
|
% foreach my $comp ($m->callers) { |
92
|
|
|
|
|
|
|
<% $comp->title %> |
93
|
|
|
|
|
|
|
% } |
94
|
|
|
|
|
|
|
----- |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
EOF |
97
|
|
|
|
|
|
|
}, |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# |
101
|
|
|
|
|
|
|
# Get command options here so that we read tests_class before user |
102
|
|
|
|
|
|
|
# calls new(). |
103
|
|
|
|
|
|
|
# |
104
|
|
|
|
|
|
|
my %cmd_options; |
105
|
|
|
|
|
|
|
GetOptions( 'create' => \$cmd_options{create}, |
106
|
|
|
|
|
|
|
'tests-to-run=s' => \$cmd_options{tests_to_run}, |
107
|
|
|
|
|
|
|
'tests-to-skip=s' => \$cmd_options{tests_to_skip}, |
108
|
|
|
|
|
|
|
'tests-class=s' => \$cmd_options{tests_class}, |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# |
112
|
|
|
|
|
|
|
# Allow options to be passed in the environment as well. |
113
|
|
|
|
|
|
|
# |
114
|
|
|
|
|
|
|
$cmd_options{tests_to_run} = $ENV{MASON_TESTS_TO_RUN} |
115
|
|
|
|
|
|
|
if !defined($cmd_options{tests_to_run}) and defined($ENV{MASON_TESTS_TO_RUN}); |
116
|
|
|
|
|
|
|
$cmd_options{tests_to_skip} = $ENV{MASON_TESTS_TO_SKIP} |
117
|
|
|
|
|
|
|
if !defined($cmd_options{tests_to_skip}) and defined($ENV{MASON_TESTS_TO_SKIP}); |
118
|
|
|
|
|
|
|
$cmd_options{tests_class} = $ENV{MASON_TESTS_CLASS} |
119
|
|
|
|
|
|
|
if !defined($cmd_options{tests_class}) and defined($ENV{MASON_TESTS_CLASS}); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# If user specifies tests_class, load that package; otherwise, |
122
|
|
|
|
|
|
|
# default it to this package. |
123
|
|
|
|
|
|
|
if (defined($cmd_options{tests_class})) { |
124
|
|
|
|
|
|
|
eval "use $cmd_options{tests_class}"; |
125
|
|
|
|
|
|
|
die $@ if $@; |
126
|
|
|
|
|
|
|
} else { |
127
|
|
|
|
|
|
|
$cmd_options{tests_class} = __PACKAGE__; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my %tests_to_run; |
131
|
|
|
|
|
|
|
if ($cmd_options{tests_to_run}) { |
132
|
|
|
|
|
|
|
for ($cmd_options{tests_to_run}) { s/^\s+//; s/\s+$// } |
133
|
|
|
|
|
|
|
my @tests_to_run = split(/\s*,\s*/, $cmd_options{tests_to_run}); |
134
|
|
|
|
|
|
|
if (grep { /[^0-9]/ } @tests_to_run) { |
135
|
|
|
|
|
|
|
@tests_to_run = sort { $a cmp $b } @tests_to_run; |
136
|
|
|
|
|
|
|
} else { |
137
|
|
|
|
|
|
|
@tests_to_run = sort { $a <=> $b } @tests_to_run; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
%tests_to_run = map { ($_, 1) } @tests_to_run; |
140
|
|
|
|
|
|
|
$Test->diag(sprintf("Running only test%s %s\n", @tests_to_run == 1 ? "" : "s", join(", ", @tests_to_run))) |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
my %tests_to_skip; |
144
|
|
|
|
|
|
|
if ($cmd_options{tests_to_skip}) { |
145
|
|
|
|
|
|
|
for ($cmd_options{tests_to_skip}) { s/^\s+//; s/\s+$// } |
146
|
|
|
|
|
|
|
my @tests_to_skip = split(/\s*,\s*/, $cmd_options{tests_to_skip}); |
147
|
|
|
|
|
|
|
%tests_to_skip = map { ($_, 1) } @tests_to_skip; |
148
|
|
|
|
|
|
|
$Test->diag(printf ("Skipping test%s %s\n", @tests_to_skip == 1 ? "" : "s", join(", ", @tests_to_skip))); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub new |
152
|
|
|
|
|
|
|
{ |
153
|
26
|
|
|
26
|
1
|
100
|
my $class = shift; |
154
|
26
|
|
|
|
|
235
|
my %p = (@_, %cmd_options); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
die "No group name provided\n" |
157
|
26
|
50
|
|
|
|
134
|
unless exists $p{name}; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
die "No description for test group provided\n" |
160
|
26
|
50
|
|
|
|
103
|
unless exists $p{description}; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
$p{pre_test_cleanup} = 1 |
163
|
26
|
100
|
|
|
|
110
|
unless exists $p{pre_test_cleanup}; |
164
|
|
|
|
|
|
|
|
165
|
26
|
|
|
|
|
268
|
return bless { |
166
|
|
|
|
|
|
|
%p, |
167
|
|
|
|
|
|
|
support => [], |
168
|
|
|
|
|
|
|
tests => [], |
169
|
|
|
|
|
|
|
}, $class; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# Returns the tests class to use for class methods - defaults to this package. |
173
|
|
|
|
|
|
|
sub tests_class |
174
|
|
|
|
|
|
|
{ |
175
|
34
|
|
|
34
|
0
|
33427
|
return $cmd_options{tests_class}; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub add_support |
179
|
|
|
|
|
|
|
{ |
180
|
146
|
|
|
146
|
1
|
704
|
my $self = shift; |
181
|
146
|
|
|
|
|
484
|
my %p = @_; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
die "'support' key array member contains no 'path' key\n" |
184
|
146
|
50
|
|
|
|
328
|
unless exists $p{path}; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
die "'support' key array member contains no 'component' key\n" |
187
|
146
|
50
|
|
|
|
279
|
unless exists $p{component}; |
188
|
|
|
|
|
|
|
|
189
|
146
|
|
|
|
|
188
|
push @{ $self->{support} }, \%p; |
|
146
|
|
|
|
|
431
|
|
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub add_test |
193
|
|
|
|
|
|
|
{ |
194
|
389
|
|
|
389
|
1
|
2618
|
my $self = shift; |
195
|
389
|
|
|
|
|
1818
|
my %p = @_; |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
die "no name provided for test\n" |
198
|
389
|
50
|
|
|
|
840
|
unless exists $p{name}; |
199
|
|
|
|
|
|
|
|
200
|
389
|
100
|
|
|
|
784
|
unless ( exists $p{path} ) |
201
|
|
|
|
|
|
|
{ |
202
|
355
|
|
66
|
|
|
1234
|
$p{path} = $p{call_path} || $p{name}; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
389
|
|
|
|
|
855
|
my $call_path = "/$self->{name}"; |
206
|
389
|
100
|
|
|
|
765
|
if ( exists $p{call_path} ) |
207
|
|
|
|
|
|
|
{ |
208
|
59
|
100
|
|
|
|
181
|
$call_path .= '/' unless substr( $p{call_path}, 0, 1 ) eq '/'; |
209
|
59
|
|
|
|
|
119
|
$call_path .= $p{call_path}; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
else |
212
|
|
|
|
|
|
|
{ |
213
|
330
|
|
|
|
|
763
|
$call_path .= '/' . $p{name}; |
214
|
|
|
|
|
|
|
} |
215
|
389
|
|
|
|
|
678
|
$p{call_path} = $call_path; |
216
|
|
|
|
|
|
|
|
217
|
389
|
100
|
|
|
|
1004
|
if ( ref($p{call_args}) eq 'HASH' ) |
|
|
100
|
|
|
|
|
|
218
|
|
|
|
|
|
|
{ |
219
|
5
|
|
|
|
|
14
|
my @lst = %{$p{call_args}}; |
|
5
|
|
|
|
|
25
|
|
220
|
5
|
|
|
|
|
15
|
$p{call_args} = \@lst; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
elsif ( !exists($p{call_args}) ) { |
223
|
381
|
|
|
|
|
774
|
$p{call_args} = []; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
die "'$p{name}' test has no description\n" |
227
|
389
|
50
|
|
|
|
825
|
unless exists $p{description}; |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
die "'$p{name}' test has no component\n" |
230
|
389
|
50
|
66
|
|
|
831
|
unless exists $p{component} || $p{skip_component}; |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
die "'$p{name}' test has no 'expect' or 'expect_error' key\n" |
233
|
389
|
0
|
66
|
|
|
930
|
unless exists $p{expect} || exists $p{expect_error} || $p{skip_expect} || $self->{create}; |
|
|
|
33
|
|
|
|
|
|
|
|
0
|
|
|
|
|
234
|
|
|
|
|
|
|
|
235
|
389
|
|
|
|
|
685
|
foreach ( qw( interp_params ) ) |
236
|
|
|
|
|
|
|
{ |
237
|
|
|
|
|
|
|
die "$_ must be a hash reference" |
238
|
389
|
50
|
66
|
|
|
1299
|
if exists $p{$_} && ! UNIVERSAL::isa( $p{$_}, 'HASH' ); |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
389
|
|
|
|
|
539
|
push @{ $self->{tests} }, \%p; |
|
389
|
|
|
|
|
1250
|
|
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub run |
245
|
|
|
|
|
|
|
{ |
246
|
25
|
|
|
25
|
1
|
218
|
my $self = shift; |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
die "No tests exist in this group" |
249
|
25
|
50
|
|
|
|
65
|
unless @{ $self->{tests} }; |
|
25
|
|
|
|
|
113
|
|
250
|
|
|
|
|
|
|
|
251
|
25
|
50
|
|
|
|
119
|
if ($DEBUG) |
252
|
|
|
|
|
|
|
{ |
253
|
0
|
0
|
|
|
|
0
|
$Test->diag( "Will " . ( $self->{create} ? '' : 'not ' ) . "create 'expect' files\n" ); |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
eval |
257
|
25
|
|
|
|
|
68
|
{ |
258
|
|
|
|
|
|
|
# 1 indicates to be silent on missing directories |
259
|
25
|
100
|
|
|
|
177
|
$self->_cleanup(1) if $self->{pre_test_cleanup}; |
260
|
25
|
|
|
|
|
186
|
$self->_make_dirs; |
261
|
25
|
|
|
|
|
211
|
$self->_write_shared_comps; |
262
|
25
|
|
|
|
|
170
|
$self->_write_support_comps; |
263
|
25
|
|
|
|
|
148
|
$self->_run_tests; |
264
|
|
|
|
|
|
|
}; |
265
|
|
|
|
|
|
|
|
266
|
25
|
50
|
|
|
|
578
|
$self->_cleanup unless $ENV{MASON_NO_CLEANUP}; |
267
|
|
|
|
|
|
|
|
268
|
25
|
50
|
|
|
|
2933
|
die $@ if $@; |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub _make_dirs |
272
|
|
|
|
|
|
|
{ |
273
|
25
|
|
|
25
|
|
85
|
my $self = shift; |
274
|
|
|
|
|
|
|
|
275
|
25
|
|
|
|
|
148
|
my $comp_root = $self->comp_root; |
276
|
25
|
|
|
|
|
149
|
my $data_dir = $self->data_dir; |
277
|
|
|
|
|
|
|
|
278
|
25
|
50
|
|
|
|
120
|
unless ( -d $self->comp_root ) |
279
|
|
|
|
|
|
|
{ |
280
|
25
|
50
|
|
|
|
179
|
$Test->diag( "Making comp_root directory: $comp_root\n" ) if $DEBUG; |
281
|
25
|
50
|
|
|
|
194
|
mkpath( $self->comp_root, 0, 0755 ) |
282
|
|
|
|
|
|
|
or die "Unable to make base test directory '$comp_root': $!"; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
25
|
100
|
|
|
|
187
|
unless ( -d $self->data_dir ) |
286
|
|
|
|
|
|
|
{ |
287
|
24
|
50
|
|
|
|
127
|
$Test->diag( "Making data_dir directory: $data_dir\n" ) if $DEBUG; |
288
|
24
|
50
|
|
|
|
118
|
mkpath( $self->data_dir, 0, 0755 ) |
289
|
|
|
|
|
|
|
or die "Unable to make base test directory '$data_dir': $!"; |
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
sub base_path |
294
|
|
|
|
|
|
|
{ |
295
|
1600
|
|
|
1600
|
1
|
2307
|
my $proto = shift; |
296
|
|
|
|
|
|
|
|
297
|
1600
|
100
|
|
|
|
3554
|
if (ref $proto) |
298
|
|
|
|
|
|
|
{ |
299
|
1596
|
|
66
|
|
|
82197
|
$proto->{base_path} ||= File::Spec->catdir( cwd(), 'mason_tests', $$ ); |
300
|
1596
|
|
|
|
|
26299
|
return $proto->{base_path}; |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
else |
303
|
|
|
|
|
|
|
{ |
304
|
4
|
|
|
|
|
25113
|
return File::Spec->catdir( cwd(), 'mason_tests', $$ ); |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
} |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
sub comp_root |
309
|
|
|
|
|
|
|
{ |
310
|
1098
|
|
|
1098
|
1
|
2015
|
my $proto = shift; |
311
|
|
|
|
|
|
|
|
312
|
1098
|
|
|
|
|
2468
|
return File::Spec->catdir( $proto->base_path, 'comps' ); |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
sub data_dir |
316
|
|
|
|
|
|
|
{ |
317
|
451
|
|
|
451
|
1
|
964
|
my $proto = shift; |
318
|
|
|
|
|
|
|
|
319
|
451
|
|
|
|
|
946
|
return File::Spec->catdir( $proto->base_path, 'data' ); |
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
sub _write_shared_comps |
323
|
|
|
|
|
|
|
{ |
324
|
25
|
|
|
25
|
|
80
|
my $self = shift; |
325
|
|
|
|
|
|
|
|
326
|
25
|
50
|
|
|
|
146
|
return unless @SHARED; |
327
|
|
|
|
|
|
|
|
328
|
25
|
|
|
|
|
140
|
foreach my $comp ( @SHARED ) |
329
|
|
|
|
|
|
|
{ |
330
|
75
|
|
|
|
|
407
|
my @path = split m(/), $comp->{path}; |
331
|
75
|
|
|
|
|
199
|
my $file = pop @path; |
332
|
|
|
|
|
|
|
|
333
|
75
|
|
|
|
|
242
|
my $dir = File::Spec->catdir( $self->comp_root, @path ); |
334
|
|
|
|
|
|
|
|
335
|
75
|
|
|
|
|
465
|
$self->write_comp( $comp->{path}, $dir, $file, $comp->{component} ); |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
} |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
sub _write_support_comps |
340
|
|
|
|
|
|
|
{ |
341
|
25
|
|
|
25
|
|
87
|
my $self = shift; |
342
|
|
|
|
|
|
|
|
343
|
25
|
100
|
|
|
|
60
|
unless ( @{ $self->{support} } ) |
|
25
|
|
|
|
|
151
|
|
344
|
|
|
|
|
|
|
{ |
345
|
5
|
50
|
|
|
|
21
|
$Test->diag( "No support comps to create\n" ) if $DEBUG; |
346
|
5
|
|
|
|
|
15
|
return; |
347
|
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
|
349
|
20
|
|
|
|
|
59
|
foreach my $supp ( @{ $self->{support} } ) |
|
20
|
|
|
|
|
104
|
|
350
|
|
|
|
|
|
|
{ |
351
|
146
|
|
|
|
|
789
|
my @path = split m(/), $supp->{path}; |
352
|
146
|
|
|
|
|
379
|
my $file = pop @path; |
353
|
|
|
|
|
|
|
|
354
|
146
|
|
|
|
|
406
|
my $dir = File::Spec->catdir( $self->comp_root, $self->{name}, @path ); |
355
|
|
|
|
|
|
|
|
356
|
146
|
|
|
|
|
488
|
$self->write_comp( $supp->{path}, $dir, $file, $supp->{component} ); |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
sub _write_test_comp |
361
|
|
|
|
|
|
|
{ |
362
|
370
|
|
|
370
|
|
660
|
my $self = shift; |
363
|
370
|
|
|
|
|
767
|
my $test = $self->{current_test}; |
364
|
|
|
|
|
|
|
|
365
|
370
|
|
|
|
|
1786
|
my @path = split m(/), $test->{path}; |
366
|
370
|
|
|
|
|
901
|
my $file = pop @path; |
367
|
|
|
|
|
|
|
|
368
|
370
|
|
|
|
|
1187
|
my $dir = File::Spec->catdir( $self->comp_root, $self->{name}, @path ); |
369
|
370
|
100
|
|
|
|
6505
|
unless ( -d $dir ) |
370
|
|
|
|
|
|
|
{ |
371
|
8
|
50
|
|
|
|
60
|
$Test->diag( "Making dir: $dir\n" ) if $DEBUG; |
372
|
8
|
50
|
|
|
|
940
|
mkpath( $dir, 0, 0755 ) |
373
|
|
|
|
|
|
|
or die "Unable to create directory '$dir': $!"; |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
370
|
|
|
|
|
1604
|
$self->write_comp( $test->{path}, $dir, $file, $test->{component} ); |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
sub write_comp |
380
|
|
|
|
|
|
|
{ |
381
|
593
|
|
|
593
|
0
|
1113
|
my $self = shift; |
382
|
593
|
|
|
|
|
2281
|
my ($path, $dir, $file, $component) = @_; |
383
|
|
|
|
|
|
|
|
384
|
593
|
100
|
|
|
|
5629
|
unless (-d $dir) |
385
|
|
|
|
|
|
|
{ |
386
|
85
|
50
|
|
|
|
288
|
$Test->diag( "Making dir: $dir\n" ) if $DEBUG; |
387
|
85
|
50
|
|
|
|
10414
|
mkpath( $dir, 0, 0755 ) |
388
|
|
|
|
|
|
|
or die "Unable to create directory '$dir': $!"; |
389
|
|
|
|
|
|
|
} |
390
|
|
|
|
|
|
|
|
391
|
593
|
|
|
|
|
5660
|
my $real_file = File::Spec->catfile( $dir, $file ); |
392
|
|
|
|
|
|
|
|
393
|
593
|
50
|
|
|
|
2068
|
$Test->diag( "Making component $path at $real_file\n" ) |
394
|
|
|
|
|
|
|
if $DEBUG; |
395
|
|
|
|
|
|
|
|
396
|
593
|
50
|
|
|
|
33055
|
open my $fh, ">$real_file" |
397
|
|
|
|
|
|
|
or die "Unable to write to '$real_file': $!"; |
398
|
593
|
50
|
|
|
|
6472
|
print $fh $component |
399
|
|
|
|
|
|
|
or die "Unable to write to '$real_file': $!"; |
400
|
593
|
50
|
|
|
|
16117
|
close $fh |
401
|
|
|
|
|
|
|
or die "Unable to write to '$real_file': $!"; |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
sub _run_tests |
405
|
|
|
|
|
|
|
{ |
406
|
25
|
|
|
25
|
|
72
|
my $self = shift; |
407
|
|
|
|
|
|
|
|
408
|
25
|
|
|
|
|
70
|
my $count = scalar @{ $self->{tests} }; |
|
25
|
|
|
|
|
423
|
|
409
|
25
|
|
|
|
|
452
|
$Test->plan( tests => $count ); |
410
|
|
|
|
|
|
|
|
411
|
25
|
50
|
|
|
|
26238
|
if ($VERBOSE) |
412
|
|
|
|
|
|
|
{ |
413
|
0
|
|
|
|
|
0
|
$Test->diag( "Running $self->{name} tests ($count tests): $self->{description}\n" ); |
414
|
|
|
|
|
|
|
} |
415
|
|
|
|
|
|
|
|
416
|
25
|
|
|
|
|
74
|
my $x = 1; |
417
|
25
|
|
|
|
|
58
|
foreach my $test ( @{ $self->{tests} } ) |
|
25
|
|
|
|
|
132
|
|
418
|
|
|
|
|
|
|
{ |
419
|
389
|
|
|
|
|
1143
|
$self->{current_test} = $test; |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
# |
422
|
|
|
|
|
|
|
# If tests_to_run or tests_to_skip were specified in the |
423
|
|
|
|
|
|
|
# environment or command line, check them to see whether to |
424
|
|
|
|
|
|
|
# run the test. |
425
|
|
|
|
|
|
|
# |
426
|
389
|
50
|
33
|
|
|
2381
|
if (%tests_to_run or %tests_to_skip) { |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
# Look for any of the specs [test_file_name:](test_number|test_name|*) |
429
|
0
|
|
|
|
|
0
|
my $wildcard_name = join(":", $self->{name}, "*"); |
430
|
0
|
|
|
|
|
0
|
my $full_name = join(":", $self->{name}, $test->{name}); |
431
|
0
|
|
|
|
|
0
|
my $full_number = join(":", $self->{name}, $x); |
432
|
0
|
|
|
|
|
0
|
my @all_specs = ($x, $test->{name}, $full_name, $full_number, $wildcard_name); |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
# If our test isn't mentioned in %tests_to_run or is |
435
|
|
|
|
|
|
|
# mentioned in %tests_to_skip, skip it. |
436
|
|
|
|
|
|
|
# |
437
|
0
|
0
|
0
|
|
|
0
|
if ((%tests_to_run and !(grep { $tests_to_run{$_} } @all_specs)) |
|
0
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
438
|
0
|
|
|
|
|
0
|
or (%tests_to_skip and (grep { $tests_to_skip{$_} } @all_specs))) { |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
# Use presence of PERL_DL_NONLAZY to decide if we are |
441
|
|
|
|
|
|
|
# running inside "make test", and if so, actually |
442
|
|
|
|
|
|
|
# print the appropriate skip response to comply with the |
443
|
|
|
|
|
|
|
# Test::Harness standard. If the user is running the |
444
|
|
|
|
|
|
|
# test by hand, this would just be clutter. |
445
|
|
|
|
|
|
|
# |
446
|
|
|
|
|
|
|
# Checking PERL_DL_NONLAZY is a hack but I don't |
447
|
|
|
|
|
|
|
# know of a better detection method. |
448
|
|
|
|
|
|
|
# |
449
|
0
|
0
|
|
|
|
0
|
$self->_skip if ($ENV{PERL_DL_NONLAZY}); |
450
|
0
|
|
|
|
|
0
|
$x++; |
451
|
0
|
|
|
|
|
0
|
next; |
452
|
|
|
|
|
|
|
} |
453
|
|
|
|
|
|
|
} |
454
|
389
|
50
|
|
|
|
1122
|
$Test->diag( "Running $test->{name} (#$x): $test->{description}\n" ) if $VERBOSE; |
455
|
389
|
100
|
|
|
|
2124
|
$self->_make_component unless $test->{skip_component}; |
456
|
389
|
|
|
|
|
1661
|
$self->_run_test; |
457
|
389
|
|
|
|
|
174133
|
$x++; |
458
|
|
|
|
|
|
|
} |
459
|
|
|
|
|
|
|
} |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
sub _make_component |
462
|
|
|
|
|
|
|
{ |
463
|
370
|
|
|
370
|
|
718
|
my $self = shift; |
464
|
370
|
|
|
|
|
775
|
my $test = $self->{current_test}; |
465
|
370
|
|
|
|
|
1164
|
$self->_write_test_comp; |
466
|
|
|
|
|
|
|
} |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
sub _make_main_interp |
469
|
|
|
|
|
|
|
{ |
470
|
382
|
|
|
382
|
|
647
|
my $self = shift; |
471
|
382
|
|
|
|
|
697
|
my $test = $self->{current_test}; |
472
|
382
|
100
|
|
|
|
1052
|
return $test->{interp} if $test->{interp}; |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
my %interp_params = ( exists $test->{interp_params} ? |
475
|
366
|
100
|
|
|
|
1157
|
%{ $test->{interp_params} } : |
|
115
|
|
|
|
|
755
|
|
476
|
|
|
|
|
|
|
() ); |
477
|
|
|
|
|
|
|
|
478
|
366
|
50
|
33
|
|
|
1191
|
if ($DEBUG && %interp_params) |
479
|
|
|
|
|
|
|
{ |
480
|
0
|
|
|
|
|
0
|
$Test->diag( "Interp params:\n" ); |
481
|
0
|
|
|
|
|
0
|
while ( my ($k, $v) = each %interp_params) |
482
|
|
|
|
|
|
|
{ |
483
|
0
|
|
|
|
|
0
|
$Test->diag( " $k => $v\n" ); |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
} |
486
|
|
|
|
|
|
|
|
487
|
366
|
|
|
|
|
1011
|
return $self->_make_interp ( comp_root => $self->comp_root, |
488
|
|
|
|
|
|
|
data_dir => $self->data_dir, |
489
|
|
|
|
|
|
|
%interp_params ); |
490
|
|
|
|
|
|
|
} |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
sub _make_interp |
493
|
|
|
|
|
|
|
{ |
494
|
376
|
|
|
376
|
|
1691
|
my ($class, %interp_params) = @_; |
495
|
|
|
|
|
|
|
|
496
|
376
|
|
|
|
|
3045
|
return HTML::Mason::Interp->new( %interp_params ); |
497
|
|
|
|
|
|
|
} |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
sub _run_test |
500
|
|
|
|
|
|
|
{ |
501
|
382
|
|
|
382
|
|
752
|
my $self = shift; |
502
|
382
|
|
|
|
|
798
|
my $test = $self->{current_test}; |
503
|
|
|
|
|
|
|
|
504
|
382
|
|
|
|
|
952
|
$self->{buffer} = ''; |
505
|
382
|
|
|
|
|
1108
|
my $interp = $self->_make_main_interp; |
506
|
382
|
50
|
|
565
|
|
3009
|
$interp->out_method( sub { for (@_) { $self->{buffer} .= $_ if defined $_ } } ); |
|
565
|
|
|
|
|
1346
|
|
|
565
|
|
|
|
|
2241
|
|
507
|
|
|
|
|
|
|
|
508
|
382
|
|
|
|
|
840
|
my $warnings = ''; |
509
|
382
|
|
|
10
|
|
2795
|
local $SIG{__WARN__} = sub { $warnings .= $_ for @_ }; |
|
10
|
|
|
|
|
68
|
|
510
|
382
|
|
|
|
|
916
|
eval { |
511
|
|
|
|
|
|
|
# Run pre_code if test has it - pass in interp |
512
|
382
|
100
|
|
|
|
1320
|
if ($test->{pre_code}) { |
513
|
18
|
|
|
|
|
63
|
$test->{pre_code}->($interp); |
514
|
|
|
|
|
|
|
} |
515
|
379
|
|
|
|
|
1236
|
$self->_execute($interp); |
516
|
|
|
|
|
|
|
}; |
517
|
|
|
|
|
|
|
|
518
|
382
|
|
|
|
|
4711
|
return $self->check_result($@, $warnings); |
519
|
|
|
|
|
|
|
} |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
sub _execute |
522
|
|
|
|
|
|
|
{ |
523
|
379
|
|
|
379
|
|
958
|
my ($self, $interp) = @_; |
524
|
379
|
|
|
|
|
786
|
my $test = $self->{current_test}; |
525
|
|
|
|
|
|
|
|
526
|
379
|
50
|
|
|
|
1040
|
$Test->diag( "Calling $test->{name} test with path: $test->{call_path}\n" ) if $DEBUG; |
527
|
379
|
100
|
|
|
|
1234
|
$test->{pretest_code}->() if $test->{pretest_code}; |
528
|
379
|
|
|
|
|
1227
|
$interp->exec( $test->{call_path}, @{$test->{call_args}} ); |
|
379
|
|
|
|
|
1754
|
|
529
|
|
|
|
|
|
|
} |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
sub check_result { |
532
|
389
|
|
|
389
|
0
|
1229
|
my ($self, $error, $warnings) = @_; |
533
|
389
|
|
|
|
|
922
|
my $test = $self->{current_test}; |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
local $HTML::Mason::Tests::TODO = $self->{current_test}{todo} |
536
|
389
|
50
|
|
|
|
1297
|
if exists $self->{current_test}{todo}; |
537
|
389
|
50
|
|
|
|
1024
|
$Test->todo if exists $self->{current_test}{todo}; |
538
|
|
|
|
|
|
|
|
539
|
389
|
100
|
|
|
|
1255
|
if ($error) |
|
|
50
|
|
|
|
|
|
540
|
|
|
|
|
|
|
{ |
541
|
74
|
50
|
|
|
|
435
|
if ( $test->{expect_error} ) |
542
|
|
|
|
|
|
|
{ |
543
|
74
|
50
|
|
|
|
753
|
if ( $error =~ /$test->{expect_error}/ ) |
544
|
|
|
|
|
|
|
{ |
545
|
74
|
|
|
|
|
310
|
return $self->_success |
546
|
|
|
|
|
|
|
} |
547
|
|
|
|
|
|
|
else |
548
|
|
|
|
|
|
|
{ |
549
|
0
|
0
|
|
|
|
0
|
if ($VERBOSE) |
550
|
|
|
|
|
|
|
{ |
551
|
0
|
|
|
|
|
0
|
$Test->diag( "Got error:\n$error\n...but expected something matching:\n$test->{expect_error}\n" ); |
552
|
|
|
|
|
|
|
} |
553
|
0
|
|
|
|
|
0
|
return $self->_fail; |
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
} |
556
|
|
|
|
|
|
|
else |
557
|
|
|
|
|
|
|
{ |
558
|
0
|
0
|
|
|
|
0
|
$Test->diag( "Unexpected error running $test->{name}:\n$error" ) if $VERBOSE; |
559
|
0
|
|
|
|
|
0
|
return $self->_fail; |
560
|
|
|
|
|
|
|
} |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
} |
563
|
|
|
|
|
|
|
elsif ( $test->{expect_error} ) |
564
|
|
|
|
|
|
|
{ |
565
|
0
|
0
|
|
|
|
0
|
$Test->diag( "Expected an error matching '$test->{expect_error}' but no error occurred - got successful output:\n$self->{buffer}\n" ) if $VERBOSE; |
566
|
0
|
|
|
|
|
0
|
return $self->_fail; |
567
|
|
|
|
|
|
|
} |
568
|
|
|
|
|
|
|
|
569
|
315
|
50
|
|
|
|
924
|
if ($self->{create}) |
570
|
|
|
|
|
|
|
{ |
571
|
0
|
|
|
|
|
0
|
$Test->diag( "Results for $test->{name}:\n$self->{buffer}\n" ); |
572
|
0
|
|
|
|
|
0
|
return; |
573
|
|
|
|
|
|
|
} |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
my $success = |
576
|
|
|
|
|
|
|
( $test->{skip_expect} ? |
577
|
|
|
|
|
|
|
1 : |
578
|
|
|
|
|
|
|
$self->check_output( actual => $self->{buffer}, expect => $test->{expect} ) |
579
|
315
|
50
|
|
|
|
1544
|
); |
580
|
|
|
|
|
|
|
|
581
|
315
|
100
|
|
|
|
896
|
if ( $test->{expect_warnings} ) |
582
|
|
|
|
|
|
|
{ |
583
|
5
|
50
|
|
|
|
74
|
unless ( $warnings =~ /$test->{expect_warnings}/ ) |
584
|
|
|
|
|
|
|
{ |
585
|
0
|
|
|
|
|
0
|
$Test->diag( "Got warnings:\n$warnings\n...but expected something matching:\n$test->{expect_warnings}\n" ); |
586
|
0
|
|
|
|
|
0
|
$success = 0; |
587
|
|
|
|
|
|
|
} |
588
|
|
|
|
|
|
|
} |
589
|
|
|
|
|
|
|
|
590
|
315
|
50
|
33
|
|
|
791
|
$Test->diag( "Got warnings: $warnings" ) if $warnings && ( ! $test->{expect_warnings} || $VERBOSE ); |
|
|
|
66
|
|
|
|
|
591
|
315
|
50
|
66
|
|
|
1023
|
$success = 0 if $test->{no_warnings} && $warnings; |
592
|
|
|
|
|
|
|
|
593
|
315
|
50
|
|
|
|
1199
|
$success ? $self->_success : $self->_fail; |
594
|
|
|
|
|
|
|
} |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
sub check_output |
597
|
|
|
|
|
|
|
{ |
598
|
315
|
|
|
315
|
1
|
1518
|
my ($self, %p) = @_; |
599
|
|
|
|
|
|
|
|
600
|
315
|
|
|
|
|
547
|
my $same; |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
# Allow a regex for $p{expect} |
603
|
315
|
100
|
|
|
|
824
|
if (ref $p{expect}) { |
604
|
11
|
|
|
|
|
180
|
$same = ($p{actual} =~ /$p{expect}/); |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
} else { |
607
|
|
|
|
|
|
|
# Whitespace at end can vary. (Or rather, it is varying in the tests, and |
608
|
|
|
|
|
|
|
# should be made not to vary, but I don't have time to fix it yet.) |
609
|
|
|
|
|
|
|
|
610
|
304
|
|
|
|
|
847
|
for ($p{actual}, $p{expect}) { s/\s+$// } |
|
608
|
|
|
|
|
4326
|
|
611
|
304
|
|
|
|
|
901
|
$same = ($p{actual} eq $p{expect}); |
612
|
|
|
|
|
|
|
} |
613
|
|
|
|
|
|
|
|
614
|
315
|
0
|
33
|
|
|
849
|
if (!$same and $VERBOSE) { |
615
|
0
|
|
|
|
|
0
|
$Test->diag( "Got ...\n-----\n$p{actual}\n-----\n ... but expected ...\n-----\n$p{expect}\n-----\n" ); |
616
|
|
|
|
|
|
|
} |
617
|
315
|
|
|
|
|
1034
|
return $same; |
618
|
|
|
|
|
|
|
} |
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
sub _fail |
621
|
|
|
|
|
|
|
{ |
622
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
623
|
0
|
|
|
|
|
0
|
my $test = $self->{current_test}; |
624
|
|
|
|
|
|
|
|
625
|
0
|
|
|
|
|
0
|
$Test->ok( 0, $test->{name} ); |
626
|
|
|
|
|
|
|
} |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
sub _success |
629
|
|
|
|
|
|
|
{ |
630
|
389
|
|
|
389
|
|
697
|
my $self = shift; |
631
|
389
|
|
|
|
|
708
|
my $test = $self->{current_test}; |
632
|
|
|
|
|
|
|
|
633
|
389
|
|
|
|
|
2304
|
$Test->ok( 1, $test->{name} ); |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
sub _skip |
637
|
|
|
|
|
|
|
{ |
638
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
639
|
0
|
|
|
|
|
0
|
my $test = $self->{current_test}; |
640
|
|
|
|
|
|
|
|
641
|
0
|
|
|
|
|
0
|
$Test->skip; |
642
|
|
|
|
|
|
|
} |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
# |
645
|
|
|
|
|
|
|
# We use our own rm_tree, rather than File::Path::rmtree, so that we |
646
|
|
|
|
|
|
|
# can silently fail to entirely remove directories. On some systems |
647
|
|
|
|
|
|
|
# .nfs files prevent total removal of directories but should not |
648
|
|
|
|
|
|
|
# otherwise interfere with tests. |
649
|
|
|
|
|
|
|
# |
650
|
|
|
|
|
|
|
sub rm_tree { |
651
|
1679
|
|
|
1679
|
0
|
3305
|
my ($path, $debug, $silent) = @_; |
652
|
1679
|
|
|
|
|
3029
|
$path =~ s#/$##; |
653
|
1679
|
100
|
|
|
|
21199
|
if (-d $path) { |
|
|
100
|
|
|
|
|
|
654
|
527
|
|
|
|
|
1347
|
local *DIR; |
655
|
527
|
50
|
|
|
|
7919
|
opendir DIR, $path or warn "Can't open $path: $!"; |
656
|
527
|
|
|
|
|
5476
|
while (defined(my $file = readdir DIR)) { |
657
|
2684
|
100
|
100
|
|
|
10732
|
next if $file eq '.' or $file eq '..'; |
658
|
1630
|
|
|
|
|
4676
|
rm_tree("$path/$file"); |
659
|
|
|
|
|
|
|
} |
660
|
527
|
|
|
|
|
3827
|
closedir DIR; |
661
|
527
|
|
|
|
|
16129
|
rmdir $path; |
662
|
|
|
|
|
|
|
} elsif (-f $path) { |
663
|
1129
|
|
|
|
|
32579
|
unlink $path; |
664
|
|
|
|
|
|
|
} else { |
665
|
23
|
50
|
|
|
|
167
|
$Test->diag( "Can't find $path to remove" ) |
666
|
|
|
|
|
|
|
unless $silent; |
667
|
|
|
|
|
|
|
} |
668
|
|
|
|
|
|
|
} |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
sub _cleanup |
671
|
|
|
|
|
|
|
{ |
672
|
49
|
|
|
49
|
|
115
|
my $self = shift; |
673
|
|
|
|
|
|
|
|
674
|
49
|
|
|
|
|
188
|
rm_tree( $self->base_path, $DEBUG, @_ ); |
675
|
|
|
|
|
|
|
} |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
1; |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
__END__ |