/
prereq.t
199 lines (169 loc) · 5.11 KB
/
prereq.t
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/usr/bin/perl -w
# This is a test of the verification of the arguments to
# WriteMakefile.
BEGIN {
unshift @INC, 't/lib';
}
use strict;
use Config;
use Test::More tests => 21;
use File::Temp qw[tempdir];
use TieOut;
use MakeMaker::Test::Utils;
use MakeMaker::Test::Setup::BFD;
use ExtUtils::MakeMaker;
chdir 't';
perl_lib; # sets $ENV{PERL5LIB} relative to t/
my $tmpdir = tempdir( DIR => '../t', CLEANUP => 1 );
use Cwd; my $cwd = getcwd; END { chdir $cwd } # so File::Temp can cleanup
chdir $tmpdir;
ok( setup_recurs(), 'setup' );
END {
ok( chdir File::Spec->updir, 'chdir updir' );
ok( teardown_recurs(), 'teardown' );
}
ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
diag("chdir failed: $!");
{
ok my $stdout = tie(*STDOUT, 'TieOut'), 'tie STDOUT';
my $warnings = '';
local $SIG{__WARN__} = sub {
if ( $Config{usecrosscompile} ) {
# libraries might not be present on the target system
# when cross-compiling
return if $_[0] =~ /\A\QWarning (mostly harmless): No library found for \E.+/
}
$warnings .= join '', @_;
};
# prerequisite warnings are disabled while building the perl core:
local $ExtUtils::MakeMaker::UNDER_CORE = 0;
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => {
strict => 0
}
);
is $warnings, '', 'basic prereq';
SKIP: {
skip 'No CMR, no version ranges', 1
unless ExtUtils::MakeMaker::_has_cpan_meta_requirements;
$warnings = '';
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => {
strict => '>= 0, <= 99999',
}
);
is $warnings, '', 'version range';
}
$warnings = '';
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => {
strict => 99999
}
);
is $warnings,
sprintf("Warning: prerequisite strict 99999 not found. We have %s.\n",
$strict::VERSION), 'strict 99999';
$warnings = '';
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => {
"I::Do::Not::Exist" => 0,
}
);
is $warnings,
"Warning: prerequisite I::Do::Not::Exist 0 not found.\n", 'non-exist prereq';
$warnings = '';
WriteMakefile(
NAME => 'Big::Dummy',
CONFIGURE_REQUIRES => {
"I::Do::Not::Configure" => 0,
}
);
is $warnings,
"Warning: prerequisite I::Do::Not::Configure 0 not found.\n", 'non-exist prereq';
$warnings = '';
WriteMakefile(
NAME => 'Big::Dummy',
TEST_REQUIRES => {
"I::Do::Not::Test" => 0,
}
);
is $warnings,
"Warning: prerequisite I::Do::Not::Test 0 not found.\n", 'non-exist prereq';
$warnings = '';
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => {
"I::Do::Not::Exist" => "",
}
);
my @warnings = split /\n/, $warnings;
is @warnings, 2, '2 warnings';
like $warnings[0], qr{^Undefined requirement for I::Do::Not::Exist\b}, 'undef version warning';
is $warnings[1], "Warning: prerequisite I::Do::Not::Exist 0 not found.", 'not found warning';
$warnings = '';
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => {
"I::Do::Not::Exist" => 0,
"strict" => 99999,
}
);
is $warnings,
"Warning: prerequisite I::Do::Not::Exist 0 not found.\n".
sprintf("Warning: prerequisite strict 99999 not found. We have %s.\n",
$strict::VERSION), '2 bad prereq warnings';
$warnings = '';
eval {
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => {
"I::Do::Not::Exist" => 0,
"Nor::Do::I" => 0,
"strict" => 99999,
},
PREREQ_FATAL => 1,
);
};
is $warnings, '', 'no warnings on PREREQ_FATAL';
is $@, <<'END', "PREREQ_FATAL";
MakeMaker FATAL: prerequisites not found.
I::Do::Not::Exist not installed
Nor::Do::I not installed
strict 99999
Please install these modules first and rerun 'perl Makefile.PL'.
END
$warnings = '';
eval {
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => {
"I::Do::Not::Exist" => 0,
},
CONFIGURE => sub {
require I::Do::Not::Exist;
},
PREREQ_FATAL => 1,
);
};
is $warnings, '', 'CONFIGURE sub non-exist req no warn';
is $@, <<'END', "PREREQ_FATAL happens before CONFIGURE";
MakeMaker FATAL: prerequisites not found.
I::Do::Not::Exist not installed
Please install these modules first and rerun 'perl Makefile.PL'.
END
$warnings = '';
@ARGV = 'PREREQ_FATAL=1';
eval {
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => { "I::Do::Not::Exist" => 0, },
);
};
is $warnings, "Warning: prerequisite I::Do::Not::Exist 0 not found.\n",
'CLI PREREQ_FATAL warns';
isnt $@, '', "CLI PREREQ_FATAL works";
}