line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Run::Plugin::TrimDisplayedFilenames; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1104296
|
use warnings; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
63
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
36
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
45
|
use 5.014; |
|
2
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
527
|
use Moose; |
|
2
|
|
|
|
|
402146
|
|
|
2
|
|
|
|
|
39
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
11772
|
use MRO::Compat; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
39
|
|
11
|
2
|
|
|
2
|
|
28
|
use File::Spec (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
35
|
|
12
|
2
|
|
|
2
|
|
9
|
use File::Basename qw/ basename dirname /; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
155
|
|
13
|
2
|
|
|
2
|
|
771
|
use List::MoreUtils (); |
|
2
|
|
|
|
|
11351
|
|
|
2
|
|
|
|
|
1266
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
extends('Test::Run::Base'); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Test::Run::Plugin::TrimDisplayedFilenames - trim the first components |
20
|
|
|
|
|
|
|
of the displayed filename to deal with excessively long ones. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 VERSION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Version 0.0126 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '0.0126'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'trim_displayed_filenames_query' => ( is => "rw", isa => "Str" ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _process_filename_dirs |
33
|
|
|
|
|
|
|
{ |
34
|
8
|
|
|
8
|
|
24
|
my ( $self, $fn, $callback ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
8
|
|
|
|
|
449
|
my $basename = basename($fn); |
37
|
8
|
|
|
|
|
196
|
my $dirpath = dirname($fn); |
38
|
|
|
|
|
|
|
|
39
|
8
|
|
|
|
|
59
|
my ( $volume, $directories, $filename ) = |
40
|
|
|
|
|
|
|
File::Spec->splitpath( $dirpath, 1 ); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# The actual manipulation. |
43
|
8
|
|
|
|
|
63
|
my $dirs = $callback->( [ File::Spec->splitdir($directories) ] ); |
44
|
|
|
|
|
|
|
|
45
|
8
|
|
|
|
|
73
|
my $final_dir = |
46
|
|
|
|
|
|
|
File::Spec->catpath( $volume, File::Spec->catdir(@$dirs), $filename ); |
47
|
|
|
|
|
|
|
|
48
|
8
|
50
|
|
|
|
34
|
if ( $final_dir eq "" ) |
49
|
|
|
|
|
|
|
{ |
50
|
8
|
|
|
|
|
294
|
return $basename; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
else |
53
|
|
|
|
|
|
|
{ |
54
|
0
|
|
|
|
|
0
|
return File::Spec->catfile( $final_dir, $basename ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _get_search_from_callback |
59
|
|
|
|
|
|
|
{ |
60
|
6
|
|
|
6
|
|
15
|
my ( $self, $options ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
6
|
50
|
|
|
|
48
|
return +( $options->{search_from} eq "start" ) |
63
|
|
|
|
|
|
|
? \&List::MoreUtils::firstidx |
64
|
|
|
|
|
|
|
: \&List::MoreUtils::lasttidx; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _get_array_portion |
68
|
|
|
|
|
|
|
{ |
69
|
6
|
|
|
6
|
|
14
|
my ( $self, $options, $dirs, $idx ) = @_; |
70
|
|
|
|
|
|
|
|
71
|
6
|
|
|
|
|
23
|
my @copy = @$dirs; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return [ |
74
|
6
|
50
|
|
|
|
32
|
+( $options->{keep_from} eq "start" ) |
75
|
|
|
|
|
|
|
? splice( @copy, 0, $idx ) |
76
|
|
|
|
|
|
|
: splice( @copy, $idx + 1 ) |
77
|
|
|
|
|
|
|
]; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _trim_filename_dir_components |
81
|
|
|
|
|
|
|
{ |
82
|
6
|
|
|
6
|
|
20
|
my ( $self, $filename, $component_callback, $options ) = @_; |
83
|
|
|
|
|
|
|
|
84
|
6
|
|
50
|
|
|
16
|
$options ||= { 'search_from' => "start", 'keep_from' => "end" }; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
return $self->_process_filename_dirs( |
87
|
|
|
|
|
|
|
$filename, |
88
|
|
|
|
|
|
|
sub { |
89
|
6
|
|
|
6
|
|
12
|
my $dirs = shift; |
90
|
|
|
|
|
|
|
|
91
|
6
|
|
|
|
|
21
|
my $idx = |
92
|
|
|
|
|
|
|
$self->_get_search_from_callback($options) |
93
|
|
|
|
|
|
|
->( $component_callback, @$dirs ); |
94
|
|
|
|
|
|
|
|
95
|
6
|
50
|
|
|
|
20
|
if ( !defined($idx) ) |
96
|
|
|
|
|
|
|
{ |
97
|
0
|
|
|
|
|
0
|
return $dirs; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
6
|
|
|
|
|
30
|
return $self->_get_array_portion( $options, $dirs, $idx ); |
101
|
|
|
|
|
|
|
}, |
102
|
6
|
|
|
|
|
42
|
); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub _process_output_leader_fn |
106
|
|
|
|
|
|
|
{ |
107
|
8
|
|
|
8
|
|
56
|
my ( $self, $fn ) = @_; |
108
|
|
|
|
|
|
|
|
109
|
8
|
|
|
|
|
321
|
my $query = $self->trim_displayed_filenames_query(); |
110
|
|
|
|
|
|
|
|
111
|
8
|
50
|
|
|
|
24
|
if ( !defined($query) ) |
112
|
|
|
|
|
|
|
{ |
113
|
0
|
|
|
|
|
0
|
return $fn; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
8
|
50
|
|
|
|
60
|
if ( $query =~ m{\A(fromre|keep):(.*)}ms ) |
117
|
|
|
|
|
|
|
{ |
118
|
8
|
|
|
|
|
28
|
my ( $cmd, $arg ) = ( $1, $2 ); |
119
|
|
|
|
|
|
|
|
120
|
8
|
100
|
|
|
|
22
|
if ( $cmd eq "fromre" ) |
121
|
|
|
|
|
|
|
{ |
122
|
6
|
|
|
|
|
87
|
my $re = qr{$arg}; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
return $self->_trim_filename_dir_components( |
125
|
|
|
|
|
|
|
$fn, |
126
|
18
|
|
|
18
|
|
71
|
sub { $_ =~ m{$re} }, |
127
|
6
|
|
|
|
|
70
|
+{ search_from => "start", keep_from => "end" } |
128
|
|
|
|
|
|
|
); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
else # $cmd eq "keep" |
131
|
|
|
|
|
|
|
{ |
132
|
|
|
|
|
|
|
# We need to decrement 1 because there's also the filename. |
133
|
2
|
|
|
|
|
13
|
my $num_keep = int($arg); |
134
|
|
|
|
|
|
|
return $self->_process_filename_dirs( |
135
|
|
|
|
|
|
|
$fn, |
136
|
|
|
|
|
|
|
sub { |
137
|
2
|
|
|
2
|
|
4
|
my @dirs = @{ shift() }; |
|
2
|
|
|
|
|
6
|
|
138
|
2
|
50
|
|
|
|
49
|
return +( $num_keep <= 1 ) |
139
|
|
|
|
|
|
|
? [] |
140
|
|
|
|
|
|
|
: [ splice( @dirs, -( $num_keep - 1 ) ) ]; |
141
|
|
|
|
|
|
|
}, |
142
|
2
|
|
|
|
|
28
|
); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
else |
146
|
|
|
|
|
|
|
{ |
147
|
|
|
|
|
|
|
# TODO - Replace with an exception object. |
148
|
0
|
|
|
|
|
0
|
die "Unrecognized trim_displayed_filename_query."; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub _calc_test_file_data_display_path |
153
|
|
|
|
|
|
|
{ |
154
|
8
|
|
|
8
|
|
888958
|
my ( $self, $idx, $test_file ) = @_; |
155
|
|
|
|
|
|
|
|
156
|
8
|
|
|
|
|
55
|
return $self->_process_output_leader_fn($test_file); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 SYNOPSIS |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
package MyTestRun; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
use Moose; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
extends('Test::Run::Plugin::TrimDisplayedFilenames'); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 FUNCTIONS |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 AUTHOR |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Shlomi Fish, C<< <shlomif at cpan.org> >> |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 BUGS |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
178
|
|
|
|
|
|
|
C<bug-test-run-plugin-alternateinterpreters at rt.cpan.org>, or through the web interface at |
179
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test::Run::Plugin::TrimDisplayedFilenames>. |
180
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
181
|
|
|
|
|
|
|
your bug as I make changes. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 SUPPORT |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
perldoc Test::Run::Plugin::TrimDisplayedFilenames |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
You can also look for information at: |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=over 4 |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item * CPAN Ratings |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Test::Run::Plugin::TrimDisplayedFilenames> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test::Run::Plugin::TrimDisplayedFilenames> |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item * MetaCPAN |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
L<http://metacpan.org/release/Test-Run-Plugin-TrimDisplayedFilenames> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=back |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Curtis "Ovid" Poe ( L<http://search.cpan.org/~ovid/> ) who gave the idea |
210
|
|
|
|
|
|
|
of testing several tests from several interpreters in one go here: |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
L<http://use.perl.org/~Ovid/journal/32092> |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 SEE ALSO |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
L<Test::Run>, L<Test::Run::CmdLine>, L<TAP::Parser>, |
217
|
|
|
|
|
|
|
L<Test::Run::CmdLine::Plugin::TrimDisplayedFilenames> |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Copyright 2007 Shlomi Fish, all rights reserved. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
This program is released under the following license: MIT X11. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
1; # End of Test::Run::Plugin::TrimDisplayedFilenames |