line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl |
2
|
|
|
|
|
|
|
# Generated by Dist::Zilla::Plugin::Test::ReportMetadata 0.3.0 |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use strict; |
5
|
|
|
|
|
|
|
use warnings; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use File::Spec; |
8
|
|
|
|
|
|
|
use Module::Metadata; |
9
|
|
|
|
|
|
|
use Sys::Hostname; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Instead of importing from Test::More |
12
|
|
|
|
|
|
|
sub diag (;@) { |
13
|
|
|
|
|
|
|
warn @_; return; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub pass () { |
17
|
|
|
|
|
|
|
print "ok 1\n1..1\n"; return; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Hide optional CPAN::Meta modules from prereq scanner |
21
|
|
|
|
|
|
|
# and check if they are available |
22
|
|
|
|
|
|
|
my $CPAN_META = 'CPAN::Meta'; |
23
|
|
|
|
|
|
|
my $CPAN_META_PRE = 'CPAN::Meta::Prereqs'; |
24
|
|
|
|
|
|
|
my @DISPLAY_VARS = grep { $_ ne 'none' } qw( AUTHOR_TESTING |
25
|
|
|
|
|
|
|
AUTOMATED_TESTING |
26
|
|
|
|
|
|
|
EXTENDED_TESTING |
27
|
|
|
|
|
|
|
NONINTERACTIVE_TESTING |
28
|
|
|
|
|
|
|
PERL_CPAN_REPORTER_CONFIG |
29
|
|
|
|
|
|
|
PERL_CR_SMOKER_CURRENT |
30
|
|
|
|
|
|
|
PERL5_CPAN_IS_RUNNING |
31
|
|
|
|
|
|
|
PERL5_CPANPLUS_IS_VERSION |
32
|
|
|
|
|
|
|
TEST_CRITIC |
33
|
|
|
|
|
|
|
TEST_SPELLING ); |
34
|
|
|
|
|
|
|
my $DO_VERIFY_PREREQS = 1; # Verify requirements? |
35
|
|
|
|
|
|
|
my @EXCLUDE = qw( ); |
36
|
|
|
|
|
|
|
my $HOST = lc hostname; |
37
|
|
|
|
|
|
|
my @INCLUDE = qw( ); |
38
|
|
|
|
|
|
|
my $LAX_VERSION_RE = # From $version::LAX |
39
|
|
|
|
|
|
|
qr{(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? |
40
|
|
|
|
|
|
|
| |
41
|
|
|
|
|
|
|
(?:\.[0-9]+) (?:_[0-9]+)? |
42
|
|
|
|
|
|
|
) | (?: |
43
|
|
|
|
|
|
|
v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? |
44
|
|
|
|
|
|
|
| |
45
|
|
|
|
|
|
|
(?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? |
46
|
|
|
|
|
|
|
) |
47
|
|
|
|
|
|
|
)}x; |
48
|
|
|
|
|
|
|
my $OSNAME = lc $^O; |
49
|
|
|
|
|
|
|
# Add static prereqs to the included modules list |
50
|
|
|
|
|
|
|
my $STATIC_PREREQS = do 't/00report-metadata.dd'; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $diag_env = sub { |
53
|
|
|
|
|
|
|
my $k = shift; my $v = exists $ENV{ $k } ? $ENV{ $k } : 'undef'; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return diag sprintf " \$%-30s %s\n", $k, $v; |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
my $max = sub { |
58
|
|
|
|
|
|
|
my $v = shift; $v = ( $_ > $v ) ? $_ : $v for @_; return $v; |
59
|
|
|
|
|
|
|
}; |
60
|
|
|
|
|
|
|
my $merge_prereqs = sub { |
61
|
|
|
|
|
|
|
my ($collector, $prereqs) = @_; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
ref $collector eq $CPAN_META_PRE # CPAN::Meta::Prereqs object |
64
|
|
|
|
|
|
|
and return $collector->with_merged_prereqs |
65
|
|
|
|
|
|
|
( CPAN::Meta::Prereqs->new( $prereqs ) ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
for my $phase (keys %{ $prereqs }) { # Raw hashrefs |
68
|
|
|
|
|
|
|
for my $type (keys %{ $prereqs->{ $phase } }) { |
69
|
|
|
|
|
|
|
for my $module (keys %{ $prereqs->{ $phase }{ $type } }) { |
70
|
|
|
|
|
|
|
$collector->{ $phase }{ $type }{ $module } |
71
|
|
|
|
|
|
|
= $prereqs->{ $phase }{ $type }{ $module }; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
return $collector; |
77
|
|
|
|
|
|
|
}; |
78
|
|
|
|
|
|
|
my $cpan_meta_ver = "${CPAN_META}->VERSION( '2.120900' )"; |
79
|
|
|
|
|
|
|
my $has_cpan_meta = eval "require ${CPAN_META}; ${cpan_meta_ver}" |
80
|
|
|
|
|
|
|
&& eval "require ${CPAN_META_PRE}"; |
81
|
|
|
|
|
|
|
# Merge all prereqs (either with ::Prereqs or a hashref) |
82
|
|
|
|
|
|
|
my $full_prereqs = $merge_prereqs-> |
83
|
|
|
|
|
|
|
( ( $has_cpan_meta ? $CPAN_META_PRE->new : {} ), $STATIC_PREREQS ); |
84
|
|
|
|
|
|
|
# Add dynamic prereqs to the included modules list (if we can) |
85
|
|
|
|
|
|
|
my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
if ($source and $has_cpan_meta) { |
88
|
|
|
|
|
|
|
if (my $meta = eval { CPAN::Meta->load_file( $source ) }) { |
89
|
|
|
|
|
|
|
$full_prereqs = $merge_prereqs->( $full_prereqs, $meta->prereqs ); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
else { $source = 'static metadata' } |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my @full_reports; |
95
|
|
|
|
|
|
|
my @dep_errors; |
96
|
|
|
|
|
|
|
my $req_hash = $has_cpan_meta ? $full_prereqs->as_string_hash : $full_prereqs; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
for my $mod (@INCLUDE) { # Add static includes into a fake section |
99
|
|
|
|
|
|
|
$req_hash->{other}{modules}{ $mod } = 0; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
for my $phase (qw( configure build test runtime develop other )) { |
103
|
|
|
|
|
|
|
$req_hash->{ $phase } or next; |
104
|
|
|
|
|
|
|
$phase eq 'develop' and not $ENV{AUTHOR_TESTING} and next; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
for my $type ( qw( requires recommends suggests conflicts modules ) ) { |
107
|
|
|
|
|
|
|
$req_hash->{ $phase }{ $type } or next; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my $title = (ucfirst $phase).' '.(ucfirst $type); |
110
|
|
|
|
|
|
|
my @reports = [ qw( Module Want Have ) ]; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
for my $mod (sort keys %{ $req_hash->{ $phase }{ $type } }) { |
113
|
|
|
|
|
|
|
$mod eq 'perl' and next; grep { $_ eq $mod } @EXCLUDE and next; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $file = $mod; $file =~ s{ :: }{/}gmx; $file .= '.pm'; |
116
|
|
|
|
|
|
|
my ($prefix) = grep { -e File::Spec->catfile( $_, $file ) } @INC; |
117
|
|
|
|
|
|
|
my $want = $req_hash->{ $phase }{ $type }{ $mod }; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
defined $want or $want = 'undef'; |
120
|
|
|
|
|
|
|
not $want and $want == 0 and $want = 'any'; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $req_string = $want eq 'any' |
123
|
|
|
|
|
|
|
? 'any version required' : "version '${want}' required"; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
if ($prefix) { |
126
|
|
|
|
|
|
|
my $path = File::Spec->catfile( $prefix, $file ); |
127
|
|
|
|
|
|
|
my $info = Module::Metadata->new_from_file( $path ); |
128
|
|
|
|
|
|
|
my $have = $info->version; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
defined $have or $have = 'undef'; |
131
|
|
|
|
|
|
|
push @reports, [ $mod, $want, $have ]; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
if ($DO_VERIFY_PREREQS and $has_cpan_meta and $type eq 'requires') { |
134
|
|
|
|
|
|
|
if ($have !~ m{ \A $LAX_VERSION_RE \z }mx) { |
135
|
|
|
|
|
|
|
push @dep_errors, |
136
|
|
|
|
|
|
|
"${mod} version '${have}' cannot be parsed (${req_string})"; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
elsif ( !$full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { |
139
|
|
|
|
|
|
|
push @dep_errors, |
140
|
|
|
|
|
|
|
"${mod} version '${have}' is not in required range '${want}'"; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
else { |
145
|
|
|
|
|
|
|
push @reports, [ $mod, $want, 'missing' ]; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
$DO_VERIFY_PREREQS and $type eq 'requires' |
148
|
|
|
|
|
|
|
and push @dep_errors, "${mod} is not installed (${req_string})"; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
if (@reports) { |
153
|
|
|
|
|
|
|
push @full_reports, "=== ${title} ===\n\n"; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
my $ml = $max->( map { length $_->[ 0 ] } @reports ); |
156
|
|
|
|
|
|
|
my $wl = $max->( map { length $_->[ 1 ] } @reports ); |
157
|
|
|
|
|
|
|
my $hl = $max->( map { length $_->[ 2 ] } @reports ); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
if ($type eq 'modules') { |
160
|
|
|
|
|
|
|
splice @reports, 1, 0, [ '-' x $ml, q(), '-' x $hl ]; |
161
|
|
|
|
|
|
|
push @full_reports, map { sprintf " %*s %*s\n", -$ml, |
162
|
|
|
|
|
|
|
$_->[ 0 ], $hl, $_->[ 2 ] } @reports; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
else { |
165
|
|
|
|
|
|
|
splice @reports, 1, 0, [ '-' x $ml, '-' x $wl, '-' x $hl ]; |
166
|
|
|
|
|
|
|
push @full_reports, map { sprintf " %*s %*s %*s\n", -$ml, |
167
|
|
|
|
|
|
|
$_->[ 0 ], $wl, $_->[ 1 ], $hl, |
168
|
|
|
|
|
|
|
$_->[ 2 ] } @reports; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
push @full_reports, "\n"; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
if (@DISPLAY_VARS) { |
177
|
|
|
|
|
|
|
diag "\nOS: ${OSNAME}, Host: ${HOST}\n"; |
178
|
|
|
|
|
|
|
diag "\n=== Environment variables ===\n\n"; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
$diag_env->( $_ ) for (@DISPLAY_VARS); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
if (@full_reports) { |
184
|
|
|
|
|
|
|
diag "\nVersions for all modules listed in ${source} (including optional ones):\n\n", @full_reports; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
if (@dep_errors) { |
188
|
|
|
|
|
|
|
diag join "\n", |
189
|
|
|
|
|
|
|
"\n*** WARNING WARNING WARNING WARNING WARNING WARNING ***\n", |
190
|
|
|
|
|
|
|
"The following REQUIRED prerequisites were not satisfied:\n", |
191
|
|
|
|
|
|
|
@dep_errors, "\n"; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
pass; |
195
|
|
|
|
|
|
|
exit 0; |