Commit | Line | Data |
---|---|---|
69ff8adf JH |
1 | #!/usr/bin/perl -w |
2 | ||
3 | # This is a test of the verification of the arguments to | |
4 | # WriteMakefile. | |
5 | ||
6 | BEGIN { | |
7 | if( $ENV{PERL_CORE} ) { | |
8 | chdir 't' if -d 't'; | |
9 | @INC = ('../lib', 'lib'); | |
10 | } | |
11 | else { | |
12 | unshift @INC, 't/lib'; | |
13 | } | |
14 | } | |
15 | ||
16 | use strict; | |
a884ca7c | 17 | use Test::More tests => 13; |
69ff8adf JH |
18 | |
19 | use TieOut; | |
20 | use MakeMaker::Test::Utils; | |
21 | ||
22 | use ExtUtils::MakeMaker; | |
23 | ||
24 | chdir 't'; | |
25 | ||
26 | perl_lib(); | |
27 | ||
28 | ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) || | |
29 | diag("chdir failed: $!"); | |
30 | ||
31 | { | |
32 | ok( my $stdout = tie *STDOUT, 'TieOut' ); | |
33 | my $warnings = ''; | |
34 | local $SIG{__WARN__} = sub { | |
35 | $warnings .= join '', @_; | |
36 | }; | |
37 | ||
a884ca7c MS |
38 | my $mm; |
39 | ||
40 | eval { | |
41 | $mm = WriteMakefile( | |
42 | NAME => 'Big::Dummy', | |
43 | VERSION_FROM => 'lib/Big/Dummy.pm', | |
44 | MAN3PODS => ' ', # common mistake | |
45 | ); | |
46 | }; | |
69ff8adf JH |
47 | |
48 | is( $warnings, <<VERIFY ); | |
49 | WARNING: MAN3PODS takes a hash reference not a string/number. | |
50 | Please inform the author. | |
51 | VERIFY | |
69ff8adf JH |
52 | |
53 | $warnings = ''; | |
a884ca7c MS |
54 | eval { |
55 | $mm = WriteMakefile( | |
56 | NAME => 'Big::Dummy', | |
57 | VERSION_FROM => 'lib/Big/Dummy.pm', | |
58 | AUTHOR => sub {}, | |
59 | ); | |
60 | }; | |
d5d4ec93 | 61 | |
69ff8adf JH |
62 | is( $warnings, <<VERIFY ); |
63 | WARNING: AUTHOR takes a string/number not a code reference. | |
64 | Please inform the author. | |
65 | VERIFY | |
66 | ||
69ff8adf JH |
67 | # LIBS accepts *both* a string or an array ref. The first cut of |
68 | # our verification did not take this into account. | |
69 | $warnings = ''; | |
70 | $mm = WriteMakefile( | |
71 | NAME => 'Big::Dummy', | |
72 | VERSION_FROM => 'lib/Big/Dummy.pm', | |
73 | LIBS => '-lwibble -lwobble', | |
74 | ); | |
d5d4ec93 | 75 | |
69ff8adf JH |
76 | # We'll get warnings about the bogus libs, that's ok. |
77 | unlike( $warnings, qr/WARNING: .* takes/ ); | |
78 | is_deeply( $mm->{LIBS}, ['-lwibble -lwobble'] ); | |
79 | ||
80 | $warnings = ''; | |
81 | $mm = WriteMakefile( | |
82 | NAME => 'Big::Dummy', | |
83 | VERSION_FROM => 'lib/Big/Dummy.pm', | |
84 | LIBS => ['-lwibble', '-lwobble'], | |
85 | ); | |
d5d4ec93 | 86 | |
69ff8adf JH |
87 | # We'll get warnings about the bogus libs, that's ok. |
88 | unlike( $warnings, qr/WARNING: .* takes/ ); | |
89 | is_deeply( $mm->{LIBS}, ['-lwibble', '-lwobble'] ); | |
90 | ||
91 | $warnings = ''; | |
a884ca7c MS |
92 | eval { |
93 | $mm = WriteMakefile( | |
94 | NAME => 'Big::Dummy', | |
95 | VERSION_FROM => 'lib/Big/Dummy.pm', | |
96 | LIBS => { wibble => "wobble" }, | |
97 | ); | |
98 | }; | |
d5d4ec93 | 99 | |
69ff8adf JH |
100 | # We'll get warnings about the bogus libs, that's ok. |
101 | like( $warnings, qr{^WARNING: LIBS takes a array reference or string/number not a hash reference}m ); | |
69ff8adf | 102 | |
d5d4ec93 MS |
103 | |
104 | $warnings = ''; | |
105 | $mm = WriteMakefile( | |
106 | NAME => 'Big::Dummy', | |
107 | WIBBLE => 'something', | |
108 | wump => { foo => 42 }, | |
109 | ); | |
110 | ||
111 | like( $warnings, qr{^WARNING: WIBBLE is not a known parameter.\n}m ); | |
112 | like( $warnings, qr{^WARNING: wump is not a known parameter.\n}m ); | |
113 | ||
114 | is( $mm->{WIBBLE}, 'something' ); | |
115 | is_deeply( $mm->{wump}, { foo => 42 } ); | |
69ff8adf | 116 | } |