line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1587310
|
use 5.008001; |
|
1
|
|
|
|
|
4
|
|
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
65
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Test::DiagINC; |
6
|
|
|
|
|
|
|
# ABSTRACT: Add Test::DiagINC to all .t files |
7
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
10
|
|
|
|
|
|
|
with( |
11
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileMunger', |
12
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileFinderUser' => { |
13
|
|
|
|
|
|
|
default_finders => [':TestFiles'], |
14
|
|
|
|
|
|
|
}, |
15
|
|
|
|
|
|
|
'Dist::Zilla::Role::PPI', |
16
|
|
|
|
|
|
|
'Dist::Zilla::Role::PrereqSource', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
7051
|
use PPI; |
|
1
|
|
|
|
|
117139
|
|
|
1
|
|
|
|
|
40
|
|
20
|
1
|
|
|
1
|
|
695
|
use Syntax::Keyword::Junction qw/any/; |
|
1
|
|
|
|
|
9159
|
|
|
1
|
|
|
|
|
8
|
|
21
|
1
|
|
|
1
|
|
103
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub munge_files { |
24
|
1
|
|
|
1
|
0
|
613651
|
my ($self) = @_; |
25
|
1
|
|
|
|
|
3
|
$self->munge_file($_) for grep { $_->name =~ /\.t$/ } @{ $self->found_files }; |
|
1
|
|
|
|
|
1655
|
|
|
1
|
|
|
|
|
8
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub munge_file { |
29
|
1
|
|
|
1
|
0
|
51
|
my ( $self, $file ) = @_; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
7
|
my $document = $self->ppi_document_for_file($file); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# using ::Comment is a hack for adding code copied from PkgVersion |
34
|
1
|
|
|
|
|
6707
|
my $add = PPI::Token::Comment->new( |
35
|
|
|
|
|
|
|
q[use if $ENV{AUTOMATED_TESTING}, 'Test::DiagINC';] . "\n" ); |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
8
|
my $was_munged; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# XXX should errors get reported? -- xdg, 2014-02-04 |
40
|
1
|
|
|
|
|
3
|
eval { |
41
|
1
|
|
|
|
|
2
|
my @includes = @{ $document->find('PPI::Statement::Include') }; |
|
1
|
|
|
|
|
9
|
|
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
1457
|
for my $s (@includes) { |
44
|
4
|
100
|
|
|
|
185
|
next if $s->version; |
45
|
3
|
100
|
|
|
|
66
|
next if $s->module eq any(qw/strict warnings/); |
46
|
1
|
|
|
|
|
37
|
$was_munged = $s->first_token->insert_before($add); |
47
|
1
|
|
|
|
|
75
|
last; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
5
|
if ($was_munged) { |
52
|
1
|
|
|
|
|
6
|
$self->save_ppi_document_to_file( $document, $file ); |
53
|
1
|
|
|
|
|
1304
|
$self->log_debug( [ "added Test::DiagINC line to %s", $file->name ] ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
0
|
|
|
|
|
0
|
$self->log( [ "skipping %s: couldn't add Test::DiagINC line", $file->name ] ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub register_prereqs { |
62
|
1
|
|
|
1
|
0
|
3620
|
my $self = shift; |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
35
|
$self->zilla->register_prereqs( |
65
|
|
|
|
|
|
|
{ |
66
|
|
|
|
|
|
|
phase => 'test', |
67
|
|
|
|
|
|
|
type => 'requires', |
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
'Test::DiagINC' => '0.002', |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# vim: ts=4 sts=4 sw=4 et: |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=pod |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=encoding UTF-8 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 NAME |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Test::DiagINC - Add Test::DiagINC to all .t files |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 VERSION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
version 0.001 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SYNOPSIS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# in dist.ini |
97
|
|
|
|
|
|
|
[Test::DiagINC] |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 DESCRIPTION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This L<Dist::Zilla> plugin adds the following L<Test::DiagINC> line to all |
102
|
|
|
|
|
|
|
C<.t> files under the C<t/> directory: |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
use if $ENV{AUTOMATED_TESTING}, 'Test::DiagINC'; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
It will be inserted before the first module loaded, excluding C<strict> and |
107
|
|
|
|
|
|
|
C<warnings>. This makes sure that it is loaded before L<Test::More>, which |
108
|
|
|
|
|
|
|
L<Test::DiagINC> requires. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
For example, it will turn this: |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
use 5.008001; |
113
|
|
|
|
|
|
|
use strict; |
114
|
|
|
|
|
|
|
use warnings; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
use Test::More; |
117
|
|
|
|
|
|
|
# etc. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Into this: |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
use 5.008001; |
122
|
|
|
|
|
|
|
use strict; |
123
|
|
|
|
|
|
|
use warnings; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
use if $ENV{AUTOMATED_TESTING}, 'Test::DiagINC'; |
126
|
|
|
|
|
|
|
use Test::More; |
127
|
|
|
|
|
|
|
# etc. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=for Pod::Coverage BUILD munge_files munge_file register_prereqs |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 RATIONALE |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Prerequisite reporting modules like L<Dist::Zilla::Plugin::Test::ReportPrereqs> |
134
|
|
|
|
|
|
|
and similar modules give an overview of prerequisites, but don't generally list |
135
|
|
|
|
|
|
|
I<deep> dependencies â i.e. the modules used by the modules you use. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::Test::PrereqsFromMeta> offers a feature to report from |
138
|
|
|
|
|
|
|
C<%INC> after loading all prerequisites, but it doesn't cover all types of |
139
|
|
|
|
|
|
|
dependencies and can't account for optional dependencies. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
What I find most relevant is knowing exactly what modules are loaded when any |
142
|
|
|
|
|
|
|
given test fails. This would include test modules, optional modules and so on. |
143
|
|
|
|
|
|
|
It is I<specific> to the failure situation. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
That sort of output is also verbose, so this plugin only generates that output |
146
|
|
|
|
|
|
|
if C<$ENV{AUTOMATED_TESTING}> is true. That means it will show up on CPAN |
147
|
|
|
|
|
|
|
Testers, but not clutter up manual test output, which seems to me like the |
148
|
|
|
|
|
|
|
right trade-off. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 SUPPORT |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 Bugs / Feature Requests |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Please report any bugs or feature requests through the issue tracker |
157
|
|
|
|
|
|
|
at L<https://github.com/dagolden/Dist-Zilla-Plugin-Test-DiagINC/issues>. |
158
|
|
|
|
|
|
|
You will be notified automatically of any progress on your issue. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 Source Code |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This is open source software. The code repository is available for |
163
|
|
|
|
|
|
|
public review and contribution under the terms of the license. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L<https://github.com/dagolden/Dist-Zilla-Plugin-Test-DiagINC> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
git clone https://github.com/dagolden/Dist-Zilla-Plugin-Test-DiagINC.git |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 AUTHOR |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
David Golden <dagolden@cpan.org> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This software is Copyright (c) 2014 by David Golden. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This is free software, licensed under: |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |