1#!/usr/bin/perl -w 2 3# This is a test of the verification of the arguments to 4# WriteMakefile. 5 6BEGIN { 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 16use strict; 17use Test::More tests => 13; 18 19use TieOut; 20use MakeMaker::Test::Utils; 21 22use ExtUtils::MakeMaker; 23 24chdir 't'; 25 26perl_lib(); 27 28ok( 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; 39 40 eval { 41 $mm = WriteMakefile( 42 NAME => 'Big::Dummy', 43 VERSION_FROM => 'lib/Big/Dummy.pm', 44 MAN3PODS => ' ', # common mistake 45 ); 46 }; 47 48 is( $warnings, <<VERIFY ); 49WARNING: MAN3PODS takes a hash reference not a string/number. 50 Please inform the author. 51VERIFY 52 53 $warnings = ''; 54 eval { 55 $mm = WriteMakefile( 56 NAME => 'Big::Dummy', 57 VERSION_FROM => 'lib/Big/Dummy.pm', 58 AUTHOR => sub {}, 59 ); 60 }; 61 62 is( $warnings, <<VERIFY ); 63WARNING: AUTHOR takes a string/number not a code reference. 64 Please inform the author. 65VERIFY 66 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 ); 75 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 ); 86 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 = ''; 92 eval { 93 $mm = WriteMakefile( 94 NAME => 'Big::Dummy', 95 VERSION_FROM => 'lib/Big/Dummy.pm', 96 LIBS => { wibble => "wobble" }, 97 ); 98 }; 99 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 ); 102 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 } ); 116} 117