line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Lite::Test::XHFTest; |
2
|
2
|
|
|
2
|
|
3552
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
59
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings qw(FATAL all NONFATAL misc); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
68
|
|
4
|
2
|
|
|
2
|
|
11
|
use parent qw(YATT::Lite::Object); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13
|
|
5
|
2
|
|
|
|
|
12
|
use YATT::Lite::MFields qw/tests numtests yatt global file_list file_dict |
6
|
|
|
|
|
|
|
cf_filename cf_ext cf_parser cf_encoding |
7
|
2
|
|
|
2
|
|
145
|
prev_item builder/; |
|
2
|
|
|
|
|
5
|
|
8
|
2
|
|
|
2
|
|
14
|
use Exporter 'import'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
107
|
|
9
|
|
|
|
|
|
|
sub MY () {__PACKAGE__} |
10
|
2
|
|
|
2
|
|
12
|
use YATT::Lite::Util qw(default dict_sort); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
141
|
|
11
|
10
|
|
|
10
|
0
|
38
|
sub default_ext {'yatt'} |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(Item); |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
11
|
use Encode; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
188
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
sub Item () {'YATT::Lite::Test::XHFTest::Item'} |
18
|
|
|
|
|
|
|
package YATT::Lite::Test::XHFTest::Item; |
19
|
2
|
|
|
2
|
|
11
|
use parent qw(YATT::Lite::Object); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
11
|
|
20
|
2
|
|
|
2
|
|
104
|
use YATT::Lite::Util qw(lexpand); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
110
|
|
21
|
2
|
|
|
|
|
12
|
use YATT::Lite::MFields qw/cf_global |
22
|
|
|
|
|
|
|
cf_parser |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
num |
25
|
|
|
|
|
|
|
realfile |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
cf_FILE |
28
|
|
|
|
|
|
|
cf_TITLE |
29
|
|
|
|
|
|
|
cf_BREAK |
30
|
|
|
|
|
|
|
cf_SKIP |
31
|
|
|
|
|
|
|
cf_TODO |
32
|
|
|
|
|
|
|
cf_PERL_MINVER |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
cf_WIDGET |
35
|
|
|
|
|
|
|
cf_RANDOM |
36
|
|
|
|
|
|
|
cf_IN |
37
|
|
|
|
|
|
|
cf_PARAM |
38
|
|
|
|
|
|
|
cf_OUT |
39
|
|
|
|
|
|
|
cf_ERROR |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
cf_REQUIRE |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
cf_TAG |
44
|
2
|
|
|
2
|
|
11
|
/; |
|
2
|
|
|
|
|
5
|
|
45
|
|
|
|
|
|
|
|
46
|
172
|
|
|
172
|
|
130826
|
sub is_runnable { shift->ntests } |
47
|
|
|
|
|
|
|
sub ntests { |
48
|
353
|
|
|
353
|
|
1063
|
my __PACKAGE__ $item = shift; |
49
|
353
|
100
|
|
|
|
1173
|
if ($item->{cf_OUT}) { |
|
|
100
|
|
|
|
|
|
50
|
256
|
|
|
|
|
1288
|
2; |
51
|
|
|
|
|
|
|
} elsif ($item->{cf_ERROR}) { |
52
|
87
|
|
|
|
|
412
|
1; |
53
|
|
|
|
|
|
|
} else { |
54
|
10
|
|
|
|
|
53
|
0; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
sub test_require { |
58
|
1
|
|
|
1
|
|
6
|
my ($self, $reqlist) = @_; |
59
|
1
|
|
|
|
|
6
|
grep {not eval qq{require $_}} lexpand($reqlist); |
|
1
|
|
|
|
|
75
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
require YATT::Lite::XHF; |
65
|
|
|
|
|
|
|
sub Parser () {'YATT::Lite::XHF'} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub list_files { |
68
|
1
|
|
|
1
|
0
|
326
|
my $pack = shift; |
69
|
|
|
|
|
|
|
map { |
70
|
1
|
50
|
|
|
|
4
|
! -d $_ ? $_ : dict_sort <$_/*.xhf>; |
|
10
|
|
|
|
|
138
|
|
71
|
|
|
|
|
|
|
} @_; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub after_new { |
75
|
10
|
|
|
10
|
1
|
26
|
my MY $self = shift; |
76
|
10
|
|
|
|
|
24
|
$self->{numtests} = 0; |
77
|
10
|
|
|
|
|
27
|
$self->{tests} = []; |
78
|
10
|
|
33
|
|
|
65
|
$self->{cf_ext} //= $self->default_ext; |
79
|
10
|
|
|
|
|
22
|
$self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
sub load { |
82
|
10
|
|
|
10
|
0
|
228
|
my $pack = shift; |
83
|
10
|
|
|
|
|
93
|
my Parser $parser = $pack->Parser->new(@_); |
84
|
10
|
|
|
|
|
46
|
my MY $self = $pack->new($parser->cf_delegate(qw(filename)) |
85
|
|
|
|
|
|
|
, parser => $parser); |
86
|
10
|
100
|
|
|
|
44
|
if (my @global = $parser->read(skip_comment => 0)) { |
87
|
3
|
|
|
|
|
13
|
$self->configure(@global); |
88
|
3
|
|
|
|
|
25
|
$parser->configure($self->cf_delegate_defined(qw(encoding))); |
89
|
|
|
|
|
|
|
} |
90
|
10
|
|
|
|
|
44
|
while (my @config = $parser->read) { |
91
|
172
|
|
|
|
|
845
|
$self->add_item($self->Item->new(@config)); |
92
|
|
|
|
|
|
|
} |
93
|
10
|
|
|
|
|
51
|
$self; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub convert_enc_array { |
97
|
2
|
|
|
2
|
0
|
19
|
my ($self, $enc, $array) = @_; |
98
|
2
|
|
|
|
|
5
|
foreach (@$array) { |
99
|
5
|
50
|
|
|
|
108
|
unless (ref $_) { |
|
|
100
|
|
|
|
|
|
100
|
4
|
|
|
|
|
13
|
$_ = decode($enc, $_) |
101
|
0
|
|
|
|
|
0
|
} elsif (ref $_ eq 'ARRAY') { |
102
|
1
|
|
|
|
|
5
|
$_ = $self->convert_enc_array($enc, $_); |
103
|
|
|
|
|
|
|
} else { |
104
|
|
|
|
|
|
|
# nop. |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
2
|
|
|
|
|
29
|
$array; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub ntests { |
111
|
10
|
|
|
10
|
0
|
53
|
my MY $self = shift; $self->{numtests} |
112
|
10
|
|
|
|
|
42
|
} |
113
|
|
|
|
|
|
|
sub add_item { |
114
|
172
|
|
|
172
|
0
|
335
|
(my MY $self, my Item $item) = @_; |
115
|
172
|
50
|
|
|
|
474
|
if ($item->{cf_global}) { |
116
|
0
|
|
|
|
|
0
|
$self->{global} = $item->{cf_global}; |
117
|
0
|
|
|
|
|
0
|
next; |
118
|
|
|
|
|
|
|
} |
119
|
172
|
|
|
|
|
282
|
push @{$self->{tests}}, $self->fixup_item($item); |
|
172
|
|
|
|
|
537
|
|
120
|
172
|
|
|
|
|
469
|
$self->{numtests} += $item->ntests; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub fixup_item { |
124
|
172
|
|
|
172
|
0
|
288
|
(my MY $self, my Item $test) = @_; |
125
|
172
|
|
|
|
|
335
|
my Item $prev = $self->{prev_item}; |
126
|
172
|
|
66
|
|
|
567
|
$test->{cf_FILE} ||= do { |
127
|
166
|
100
|
100
|
|
|
820
|
if ($prev && $prev->{cf_FILE} =~ m{%d}) { |
128
|
|
|
|
|
|
|
$prev->{cf_FILE} |
129
|
155
|
|
|
|
|
544
|
} else { |
130
|
11
|
|
|
|
|
48
|
"f%d.$self->{cf_ext}" |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
}; |
133
|
|
|
|
|
|
|
|
134
|
172
|
|
|
|
|
302
|
$test->{realfile} = do { |
135
|
172
|
100
|
|
|
|
361
|
if ($test->{cf_IN}) { |
136
|
2
|
|
|
2
|
|
17
|
no if $] >= 5.021002, warnings => qw/redundant/; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
21
|
|
137
|
145
|
|
100
|
|
|
245
|
sprintf($test->{cf_FILE}, 1+@{$self->{file_list} //= []}) |
|
145
|
|
|
|
|
773
|
|
138
|
|
|
|
|
|
|
} else { |
139
|
|
|
|
|
|
|
$prev->{realfile} |
140
|
27
|
|
|
|
|
57
|
} |
141
|
|
|
|
|
|
|
}; |
142
|
|
|
|
|
|
|
|
143
|
172
|
|
33
|
|
|
524
|
$test->{cf_WIDGET} ||= do { |
144
|
172
|
|
|
|
|
303
|
my $widget = $test->{realfile}; |
145
|
172
|
|
|
|
|
762
|
$widget =~ s{\.\w+$}{}; |
146
|
172
|
|
|
|
|
376
|
$widget =~ s{/}{:}g; |
147
|
172
|
|
|
|
|
566
|
$widget; |
148
|
|
|
|
|
|
|
}; |
149
|
|
|
|
|
|
|
|
150
|
172
|
100
|
|
|
|
428
|
if ($test->{cf_IN}) { |
151
|
145
|
50
|
|
|
|
417
|
if (my $conflict = $self->{file_dict}{$test->{realfile}}) { |
152
|
0
|
|
|
|
|
0
|
die "FILE name confliction in test $test"; |
153
|
|
|
|
|
|
|
} |
154
|
145
|
|
|
|
|
376
|
$self->{file_dict}{$test->{realfile}} = $test; |
155
|
145
|
|
|
|
|
251
|
push @{$self->{file_list}}, $test->{realfile}; |
|
145
|
|
|
|
|
362
|
|
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
172
|
100
|
100
|
|
|
548
|
if ($test->{cf_OUT} || $test->{cf_ERROR}) { |
159
|
167
|
|
0
|
|
|
386
|
$test->{cf_WIDGET} ||= $prev && $prev->{cf_WIDGET}; |
|
|
|
33
|
|
|
|
|
160
|
167
|
100
|
100
|
|
|
480
|
if (not $test->{cf_TITLE} and $prev) { |
161
|
19
|
|
|
|
|
78
|
$test->{num} = default($prev->{num}, 0) + 1; |
162
|
19
|
|
|
|
|
66
|
$test->{cf_TITLE} = $prev->{cf_TITLE}; |
163
|
|
|
|
|
|
|
} |
164
|
167
|
|
|
|
|
290
|
$self->{prev_item} = $test; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
172
|
|
|
|
|
369
|
$test; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub as_vfs_data { |
171
|
10
|
|
|
10
|
0
|
11511
|
my MY $self = shift; |
172
|
10
|
|
|
|
|
28
|
my (%result); |
173
|
|
|
|
|
|
|
# 記述の順番どおりに作成 |
174
|
10
|
|
|
|
|
22
|
foreach my $fn (@{$self->{file_list}}) { |
|
10
|
|
|
|
|
50
|
|
175
|
145
|
|
|
|
|
350
|
my Item $item = $self->{file_dict}{$fn}; |
176
|
145
|
|
|
|
|
291
|
my @path = split m|/|, $fn; |
177
|
145
|
|
|
|
|
319
|
my $path_cursor = path_cursor(\%result, \@path); |
178
|
145
|
50
|
|
|
|
559
|
$path[0] =~ s|\.(\w+)$|| |
179
|
|
|
|
|
|
|
or die "Can't handle filename as vfs key: $fn"; |
180
|
145
|
|
|
|
|
290
|
my $ext = $1; |
181
|
145
|
50
|
|
|
|
466
|
if (my $sub = $self->can("convert_$ext")) { |
182
|
0
|
|
|
|
|
0
|
$sub->($self, $path_cursor, $item) |
183
|
|
|
|
|
|
|
} else { |
184
|
|
|
|
|
|
|
# XXX: 既に配列になってると困るよね。 rc 系を後回しにすれば大丈夫? |
185
|
145
|
50
|
|
|
|
397
|
unless (defined $item->{cf_IN}) { |
186
|
0
|
|
|
|
|
0
|
die "undef IN" |
187
|
|
|
|
|
|
|
} |
188
|
145
|
|
|
|
|
514
|
$path_cursor->[0]{$path[0]} = $item->{cf_IN}; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
} |
191
|
10
|
|
|
|
|
39
|
\%result; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub path_cursor { |
195
|
145
|
|
|
145
|
0
|
245
|
my ($top, $path) = @_; |
196
|
|
|
|
|
|
|
# path を一個残して、vivify する。 |
197
|
|
|
|
|
|
|
# そこにいたる経路を cursor として返す。 |
198
|
145
|
|
|
|
|
245
|
my $cursor = [$top]; |
199
|
145
|
|
|
|
|
344
|
while (@$path > 1) { |
200
|
1
|
|
|
|
|
4
|
my $nm = shift @$path; |
201
|
1
|
|
50
|
|
|
91
|
$cursor = [$cursor->[0]{$nm} ||= {}, $cursor]; |
202
|
|
|
|
|
|
|
} |
203
|
145
|
|
|
|
|
237
|
$cursor; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
1; |