test failure: lib/ExtUtils/t/Installed.t
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / writemakefile_args.t
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;
17 use Test::More tests => 12;
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
38     my $mm = WriteMakefile(
39         NAME            => 'Big::Dummy',
40         VERSION_FROM    => 'lib/Big/Dummy.pm',
41         MAN3PODS        => ' ', # common mistake
42     );
43
44     is( $warnings, <<VERIFY );
45 WARNING: MAN3PODS takes a hash reference not a string/number.
46          Please inform the author.
47 VERIFY
48     is_deeply( $mm->{MAN3PODS}, {}, 'Wrong argument type corrected' );
49
50     $warnings = '';
51     $mm = WriteMakefile(
52         NAME            => 'Big::Dummy',
53         VERSION_FROM    => 'lib/Big/Dummy.pm',
54         AUTHOR          => sub {},
55     );
56     
57     is( $warnings, <<VERIFY );
58 WARNING: AUTHOR takes a string/number not a code reference.
59          Please inform the author.
60 VERIFY
61
62     is_deeply( $mm->{AUTHOR}, '' );
63
64
65     # LIBS accepts *both* a string or an array ref.  The first cut of
66     # our verification did not take this into account.
67     $warnings = '';
68     $mm = WriteMakefile(
69         NAME            => 'Big::Dummy',
70         VERSION_FROM    => 'lib/Big/Dummy.pm',
71         LIBS            => '-lwibble -lwobble',
72     );
73     
74     # We'll get warnings about the bogus libs, that's ok.
75     unlike( $warnings, qr/WARNING: .* takes/ );
76     is_deeply( $mm->{LIBS}, ['-lwibble -lwobble'] );
77
78     $warnings = '';
79     $mm = WriteMakefile(
80         NAME            => 'Big::Dummy',
81         VERSION_FROM    => 'lib/Big/Dummy.pm',
82         LIBS            => ['-lwibble', '-lwobble'],
83     );
84     
85     # We'll get warnings about the bogus libs, that's ok.
86     unlike( $warnings, qr/WARNING: .* takes/ );
87     is_deeply( $mm->{LIBS}, ['-lwibble', '-lwobble'] );
88
89     $warnings = '';
90     $mm = WriteMakefile(
91         NAME            => 'Big::Dummy',
92         VERSION_FROM    => 'lib/Big/Dummy.pm',
93         LIBS            => { wibble => "wobble" },
94     );
95     
96     # We'll get warnings about the bogus libs, that's ok.
97     like( $warnings, qr{^WARNING: LIBS takes a array reference or string/number not a hash reference}m );
98     is_deeply( $mm->{LIBS}, [] );
99
100 }