Commit | Line | Data |
69ff8adf |
1 | #!/usr/bin/perl -w |
2 | |
3 | # This is a test of the verification of the arguments to |
4 | # WriteMakefile. |
5 | |
6 | BEGIN { |
b78fd716 |
7 | unshift @INC, 't/lib'; |
69ff8adf |
8 | } |
9 | |
10 | use strict; |
5bdf71cc |
11 | use Test::More tests => 35; |
69ff8adf |
12 | |
13 | use TieOut; |
14 | use MakeMaker::Test::Utils; |
a7d1454b |
15 | use MakeMaker::Test::Setup::BFD; |
69ff8adf |
16 | |
17 | use ExtUtils::MakeMaker; |
18 | |
19 | chdir 't'; |
20 | |
21 | perl_lib(); |
22 | |
a7d1454b |
23 | ok( setup_recurs(), 'setup' ); |
24 | END { |
25 | ok( chdir File::Spec->updir ); |
26 | ok( teardown_recurs(), 'teardown' ); |
27 | } |
28 | |
69ff8adf |
29 | ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) || |
30 | diag("chdir failed: $!"); |
31 | |
32 | { |
33 | ok( my $stdout = tie *STDOUT, 'TieOut' ); |
34 | my $warnings = ''; |
35 | local $SIG{__WARN__} = sub { |
36 | $warnings .= join '', @_; |
37 | }; |
38 | |
a884ca7c |
39 | my $mm; |
40 | |
41 | eval { |
42 | $mm = WriteMakefile( |
43 | NAME => 'Big::Dummy', |
44 | VERSION_FROM => 'lib/Big/Dummy.pm', |
45 | MAN3PODS => ' ', # common mistake |
46 | ); |
47 | }; |
69ff8adf |
48 | |
49 | is( $warnings, <<VERIFY ); |
277189c8 |
50 | WARNING: MAN3PODS takes a HASH reference not a string/number. |
69ff8adf |
51 | Please inform the author. |
52 | VERIFY |
69ff8adf |
53 | |
54 | $warnings = ''; |
a884ca7c |
55 | eval { |
56 | $mm = WriteMakefile( |
57 | NAME => 'Big::Dummy', |
58 | VERSION_FROM => 'lib/Big/Dummy.pm', |
59 | AUTHOR => sub {}, |
60 | ); |
61 | }; |
d5d4ec93 |
62 | |
69ff8adf |
63 | is( $warnings, <<VERIFY ); |
277189c8 |
64 | WARNING: AUTHOR takes a string/number not a CODE reference. |
69ff8adf |
65 | Please inform the author. |
66 | VERIFY |
67 | |
69ff8adf |
68 | # LIBS accepts *both* a string or an array ref. The first cut of |
69 | # our verification did not take this into account. |
70 | $warnings = ''; |
71 | $mm = WriteMakefile( |
72 | NAME => 'Big::Dummy', |
73 | VERSION_FROM => 'lib/Big/Dummy.pm', |
74 | LIBS => '-lwibble -lwobble', |
75 | ); |
d5d4ec93 |
76 | |
69ff8adf |
77 | # We'll get warnings about the bogus libs, that's ok. |
78 | unlike( $warnings, qr/WARNING: .* takes/ ); |
79 | is_deeply( $mm->{LIBS}, ['-lwibble -lwobble'] ); |
80 | |
81 | $warnings = ''; |
82 | $mm = WriteMakefile( |
83 | NAME => 'Big::Dummy', |
84 | VERSION_FROM => 'lib/Big/Dummy.pm', |
85 | LIBS => ['-lwibble', '-lwobble'], |
86 | ); |
d5d4ec93 |
87 | |
69ff8adf |
88 | # We'll get warnings about the bogus libs, that's ok. |
89 | unlike( $warnings, qr/WARNING: .* takes/ ); |
90 | is_deeply( $mm->{LIBS}, ['-lwibble', '-lwobble'] ); |
91 | |
92 | $warnings = ''; |
a884ca7c |
93 | eval { |
94 | $mm = WriteMakefile( |
95 | NAME => 'Big::Dummy', |
96 | VERSION_FROM => 'lib/Big/Dummy.pm', |
97 | LIBS => { wibble => "wobble" }, |
98 | ); |
99 | }; |
d5d4ec93 |
100 | |
69ff8adf |
101 | # We'll get warnings about the bogus libs, that's ok. |
277189c8 |
102 | like( $warnings, qr{^WARNING: LIBS takes a ARRAY reference or string/number not a HASH reference}m ); |
69ff8adf |
103 | |
d5d4ec93 |
104 | |
105 | $warnings = ''; |
106 | $mm = WriteMakefile( |
107 | NAME => 'Big::Dummy', |
108 | WIBBLE => 'something', |
109 | wump => { foo => 42 }, |
110 | ); |
111 | |
112 | like( $warnings, qr{^WARNING: WIBBLE is not a known parameter.\n}m ); |
113 | like( $warnings, qr{^WARNING: wump is not a known parameter.\n}m ); |
114 | |
115 | is( $mm->{WIBBLE}, 'something' ); |
116 | is_deeply( $mm->{wump}, { foo => 42 } ); |
277189c8 |
117 | |
118 | |
119 | # Test VERSION |
120 | $warnings = ''; |
121 | eval { |
122 | $mm = WriteMakefile( |
2e65e370 |
123 | NAME => 'Big::Dummy', |
124 | VERSION => [1,2,3], |
277189c8 |
125 | ); |
126 | }; |
127 | like( $warnings, qr{^WARNING: VERSION takes a version object or string/number} ); |
128 | |
129 | $warnings = ''; |
130 | eval { |
131 | $mm = WriteMakefile( |
2e65e370 |
132 | NAME => 'Big::Dummy', |
133 | VERSION => 1.002_003, |
277189c8 |
134 | ); |
135 | }; |
136 | is( $warnings, '' ); |
137 | is( $mm->{VERSION}, '1.002003' ); |
138 | |
139 | $warnings = ''; |
140 | eval { |
141 | $mm = WriteMakefile( |
2e65e370 |
142 | NAME => 'Big::Dummy', |
143 | VERSION => '1.002_003', |
277189c8 |
144 | ); |
145 | }; |
146 | is( $warnings, '' ); |
147 | is( $mm->{VERSION}, '1.002_003' ); |
148 | |
149 | |
150 | $warnings = ''; |
151 | eval { |
152 | $mm = WriteMakefile( |
2e65e370 |
153 | NAME => 'Big::Dummy', |
154 | VERSION => bless {}, "Some::Class", |
277189c8 |
155 | ); |
156 | }; |
157 | like( $warnings, '/^WARNING: VERSION takes a version object or string/number not a Some::Class object/' ); |
158 | |
159 | |
160 | SKIP: { |
2e65e370 |
161 | skip("Can't test version objects", 8) unless eval { require version }; |
277189c8 |
162 | version->import; |
163 | |
164 | my $version = version->new("1.2.3"); |
165 | $warnings = ''; |
2e65e370 |
166 | ok eval { |
277189c8 |
167 | $mm = WriteMakefile( |
2e65e370 |
168 | NAME => 'Big::Dummy', |
169 | VERSION => $version, |
277189c8 |
170 | ); |
2e65e370 |
171 | } || diag $@; |
277189c8 |
172 | is( $warnings, '' ); |
173 | isa_ok( $mm->{VERSION}, 'version' ); |
174 | is( $mm->{VERSION}, $version ); |
175 | |
176 | $warnings = ''; |
177 | $version = qv('1.2.3'); |
2e65e370 |
178 | ok eval { |
277189c8 |
179 | $mm = WriteMakefile( |
2e65e370 |
180 | NAME => 'Big::Dummy', |
181 | VERSION => $version, |
277189c8 |
182 | ); |
2e65e370 |
183 | } || diag $@; |
277189c8 |
184 | is( $warnings, '' ); |
185 | isa_ok( $mm->{VERSION}, 'version' ); |
186 | is( $mm->{VERSION}, $version ); |
187 | } |
5bdf71cc |
188 | |
189 | |
190 | # DISTNAME |
191 | $warnings = ''; |
192 | eval { |
193 | $mm = WriteMakefile( |
194 | NAME => 'Big::Dummy', |
195 | VERSION => '1.00', |
196 | DISTNAME => "Hooballa", |
197 | ); |
198 | }; |
199 | is( $warnings, '' ); |
200 | is( $mm->{DISTNAME}, "Hooballa" ); |
201 | is( $mm->{DISTVNAME}, $Is_VMS ? "Hooballa-1_00" : "Hooballa-1.00" ); |
202 | |
203 | |
204 | # DISTVNAME (rt.cpan.org 43217) |
205 | $warnings = ''; |
206 | eval { |
207 | $mm = WriteMakefile( |
208 | NAME => 'Big::Dummy', |
209 | VERSION => 1.00, |
210 | DISTVNAME => "Hooballoo", |
211 | ); |
212 | }; |
213 | is( $warnings, '' ); |
214 | is( $mm->{DISTVNAME}, 'Hooballoo' ); |
2e65e370 |
215 | } |