line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::ExtraTests 6.030; |
2
|
|
|
|
|
|
|
# ABSTRACT: rewrite ./xt tests to ./t tests with skips |
3
|
|
|
|
|
|
|
|
4
|
11
|
|
|
11
|
|
8118
|
use Moose; |
|
11
|
|
|
|
|
35
|
|
|
11
|
|
|
|
|
106
|
|
5
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FileMunger'; |
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
79462
|
use Dist::Zilla::Pragmas; |
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
97
|
|
8
|
|
|
|
|
|
|
|
9
|
11
|
|
|
11
|
|
157
|
use namespace::autoclean; |
|
11
|
|
|
|
|
35
|
|
|
11
|
|
|
|
|
128
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
12
|
|
|
|
|
|
|
#pod |
13
|
|
|
|
|
|
|
#pod This plugin rewrites tests found in the following directories: |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod ./xt/author - tests for author testing (env AUTHOR_TESTING is true) |
16
|
|
|
|
|
|
|
#pod ./xt/release - tests for pre-release testers (env RELEASE_TESTING is true) |
17
|
|
|
|
|
|
|
#pod ./xt/smoke - tests for automated testers (env AUTOMATED_TESTING is true) |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod The tests are renamed and moved to F<./t>, and they are rewritten to include |
20
|
|
|
|
|
|
|
#pod some simple Perl code to skip all included tests if the correct env vars are |
21
|
|
|
|
|
|
|
#pod not set. |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod =cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub munge_file { |
26
|
84
|
|
|
84
|
0
|
181
|
my ($self, $file) = @_; |
27
|
|
|
|
|
|
|
|
28
|
84
|
100
|
|
|
|
257
|
return unless $file->name =~ m{\Axt/(smoke|author|release)/.+\.t\z}; |
29
|
20
|
|
|
|
|
91
|
my $method = "_rewrite_$1\_test"; |
30
|
|
|
|
|
|
|
|
31
|
20
|
|
|
|
|
464
|
$self->log("rewriting $1 test " . $file->name); |
32
|
|
|
|
|
|
|
|
33
|
20
|
|
|
|
|
5232
|
$self->$method($file); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _rewrite_smoke_test { |
37
|
1
|
|
|
1
|
|
4
|
my ($self, $file) = @_; |
38
|
1
|
|
|
|
|
5
|
$self->_rewrite($file, 'AUTOMATED_TESTING', '"smoke bot" testing'); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _rewrite_author_test { |
42
|
18
|
|
|
18
|
|
60
|
my ($self, $file) = @_; |
43
|
18
|
|
|
|
|
83
|
$self->_rewrite($file, 'AUTHOR_TESTING', 'testing by the author'); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _rewrite_release_test { |
47
|
1
|
|
|
1
|
|
3
|
my ($self, $file) = @_; |
48
|
1
|
|
|
|
|
4
|
$self->_rewrite($file, 'RELEASE_TESTING', 'release candidate testing'); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _rewrite { |
52
|
20
|
|
|
20
|
|
68
|
my ($self, $file, $env, $msg) = @_; |
53
|
|
|
|
|
|
|
|
54
|
20
|
|
|
|
|
81
|
my $name = $file->name =~ s{^xt/([^/]+)/}{t/$1-}r; |
55
|
|
|
|
|
|
|
|
56
|
20
|
|
|
|
|
100
|
$file->name($name); |
57
|
|
|
|
|
|
|
|
58
|
20
|
|
|
|
|
98
|
my @lines = split /\n/, $file->content; |
59
|
20
|
50
|
|
|
|
110
|
my $after = $lines[0] =~ /\A#!/ ? 1 : 0; |
60
|
20
|
|
|
|
|
108
|
splice @lines, $after, 0, qq| |
61
|
|
|
|
|
|
|
BEGIN { |
62
|
|
|
|
|
|
|
unless (\$ENV{$env}) { |
63
|
|
|
|
|
|
|
print qq{1..0 # SKIP these tests are for $msg\\n}; |
64
|
|
|
|
|
|
|
exit |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|; |
68
|
|
|
|
|
|
|
|
69
|
20
|
|
|
|
|
134
|
$file->content(join "\n", @lines, ''); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=pod |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=encoding UTF-8 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 NAME |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Dist::Zilla::Plugin::ExtraTests - rewrite ./xt tests to ./t tests with skips |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 VERSION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
version 6.030 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 DESCRIPTION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This plugin rewrites tests found in the following directories: |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
./xt/author - tests for author testing (env AUTHOR_TESTING is true) |
94
|
|
|
|
|
|
|
./xt/release - tests for pre-release testers (env RELEASE_TESTING is true) |
95
|
|
|
|
|
|
|
./xt/smoke - tests for automated testers (env AUTOMATED_TESTING is true) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The tests are renamed and moved to F<./t>, and they are rewritten to include |
98
|
|
|
|
|
|
|
some simple Perl code to skip all included tests if the correct env vars are |
99
|
|
|
|
|
|
|
not set. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 PERL VERSION |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
104
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
105
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
106
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
109
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
110
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
111
|
|
|
|
|
|
|
the minimum required perl. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Ricardo SIGNES 😏 <cpan@semiotic.systems> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This software is copyright (c) 2023 by Ricardo SIGNES. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
122
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |