1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
BEGIN {
chdir '..' if -d '../t';
unshift @INC, 't/lib';
use lib 'lib';
}
use strict;
use warnings;
use Test::More 'no_plan';
require ExtUtils::MM_Any;
sub ExtUtils::MM_Any::quote_literal { $_[1] }
my $new_mm = sub {
return bless { ARGS => {@_}, @_ }, 'ExtUtils::MM_Any';
};
my $warn_ok = sub {
my($code, $want, $name) = @_;
my @have;
my $ret;
{
local $SIG{__WARN__} = sub { push @have, @_ };
$ret = $code->();
}
like join("", @have), $want, $name;
return $ret;
};
my $version_regex = qr/version: ''/;
my $version_action = "they're converted to empty string";
note "Filename as version"; {
my $mm = $new_mm->(
DISTNAME => 'Net::FTP::Recursive',
VERSION => 'Recursive.pm',
);
my $res = $warn_ok->(
sub { eval { $mm->metafile_target } },
qr{Can't parse version 'Recursive.pm'}
);
ok $res, 'we know how to deal with bogus versions defined in Makefile.PL';
like $res, $version_regex, $version_action;
}
note "'undef' version from parse_version"; {
my $mm = $new_mm->(
DISTNAME => 'Image::Imgur',
VERSION => 'undef',
);
my $res = $warn_ok->(
sub { eval { $mm->metafile_target } },
qr{Can't parse version 'undef'}
);
ok $res, q|when there's no $VERSION in Module.pm, $self->{VERSION} = 'undef'; via MM_Unix::parse_version and we know how to deal with that|;
like $res, $version_regex, $version_action;
}
note "x.y.z version"; {
my $mm = $new_mm->(
DISTNAME => 'SQL::Library',
VERSION => 0.0.3,
);
# It would be more useful if the warning got translated to visible characters
my $res = $warn_ok->(
sub { eval { $mm->metafile_target } },
qr{Can't parse version '\x00\x00\x03'}
);
ok $res, q|we know how to deal with our $VERSION = 0.0.3; style versions defined in the module|;
like $res, $version_regex, $version_action;
}
note ".5 version"; {
my $mm = $new_mm->(
DISTNAME => 'Array::Suffix',
VERSION => '.5',
);
my $res = $warn_ok->(
sub { eval { $mm->metafile_target } },
qr{Can't parse version '.5'}
);
ok $res, q|we know how to deal with our $VERSION = '.5'; style versions defined in the module|;
like $res, $version_regex, $version_action;
}
note "Non-camel case metadata"; {
my $mm = $new_mm->(
DISTNAME => 'Attribute::Signature',
META_MERGE => {
resources => {
repository => 'http://github.com/chorny/Attribute-Signature',
'Repository-clone' => 'git://github.com/chorny/Attribute-Signature.git',
},
},
);
my $res = eval { $mm->metafile_target };
ok $res, q|we know how to deal with non-camel-cased custom meta resource keys defined in Makefile.PL|;
like $res, qr/x_Repositoryclone/, "they're camel-cased";
}
note "version object in provides"; {
my $mm = $new_mm->(
DISTNAME => 'CPAN::Testers::ParseReport',
VERSION => '2.34',
META_ADD => {
provides => {
"CPAN::Testers::ParseReport" => {
version => version->new("v1.2.3"),
file => "lib/CPAN/Testers/ParseReport.pm"
}
}
},
);
my $res = eval { $mm->metafile_target };
like $res, qr{version: \s* v1.2.3}x;
}
|