1#!/usr/bin/perl -w 2 3# This is a test of the verification of the arguments to 4# WriteMakefile. 5 6BEGIN { 7 unshift @INC, 't/lib'; 8} 9 10use strict; 11use Test::More tests => 16; 12use File::Temp qw[tempdir]; 13 14use TieOut; 15use MakeMaker::Test::Utils; 16use MakeMaker::Test::Setup::BFD; 17 18use ExtUtils::MakeMaker; 19 20my $tmpdir = tempdir( DIR => 't', CLEANUP => 1 ); 21chdir $tmpdir; 22 23perl_lib(); 24 25ok( setup_recurs(), 'setup' ); 26END { 27 ok( chdir File::Spec->updir ); 28 ok( teardown_recurs(), 'teardown' ); 29} 30 31ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) || 32 diag("chdir failed: $!"); 33 34{ 35 ok( my $stdout = tie *STDOUT, 'TieOut' ); 36 my $warnings = ''; 37 local $SIG{__WARN__} = sub { 38 $warnings .= join '', @_; 39 }; 40 # prerequisite warnings are disabled while building the perl core: 41 local $ENV{PERL_CORE} = 0; 42 43 WriteMakefile( 44 NAME => 'Big::Dummy', 45 PREREQ_PM => { 46 strict => 0 47 } 48 ); 49 is $warnings, ''; 50 51 $warnings = ''; 52 WriteMakefile( 53 NAME => 'Big::Dummy', 54 PREREQ_PM => { 55 strict => 99999 56 } 57 ); 58 is $warnings, 59 sprintf("Warning: prerequisite strict 99999 not found. We have %s.\n", 60 $strict::VERSION); 61 62 $warnings = ''; 63 WriteMakefile( 64 NAME => 'Big::Dummy', 65 PREREQ_PM => { 66 "I::Do::Not::Exist" => 0, 67 } 68 ); 69 is $warnings, 70 "Warning: prerequisite I::Do::Not::Exist 0 not found.\n"; 71 72 73 $warnings = ''; 74 WriteMakefile( 75 NAME => 'Big::Dummy', 76 PREREQ_PM => { 77 "I::Do::Not::Exist" => "", 78 } 79 ); 80 my @warnings = split /\n/, $warnings; 81 is @warnings, 2; 82 like $warnings[0], qr{^Unparsable version '' for prerequisite I::Do::Not::Exist\b}; 83 is $warnings[1], "Warning: prerequisite I::Do::Not::Exist 0 not found."; 84 85 86 $warnings = ''; 87 WriteMakefile( 88 NAME => 'Big::Dummy', 89 PREREQ_PM => { 90 "I::Do::Not::Exist" => 0, 91 "strict" => 99999, 92 } 93 ); 94 is $warnings, 95 "Warning: prerequisite I::Do::Not::Exist 0 not found.\n". 96 sprintf("Warning: prerequisite strict 99999 not found. We have %s.\n", 97 $strict::VERSION); 98 99 $warnings = ''; 100 eval { 101 WriteMakefile( 102 NAME => 'Big::Dummy', 103 PREREQ_PM => { 104 "I::Do::Not::Exist" => 0, 105 "Nor::Do::I" => 0, 106 "strict" => 99999, 107 }, 108 PREREQ_FATAL => 1, 109 ); 110 }; 111 112 is $warnings, ''; 113 is $@, <<'END', "PREREQ_FATAL"; 114MakeMaker FATAL: prerequisites not found. 115 I::Do::Not::Exist not installed 116 Nor::Do::I not installed 117 strict 99999 118 119Please install these modules first and rerun 'perl Makefile.PL'. 120END 121 122 123 $warnings = ''; 124 eval { 125 WriteMakefile( 126 NAME => 'Big::Dummy', 127 PREREQ_PM => { 128 "I::Do::Not::Exist" => 0, 129 }, 130 CONFIGURE => sub { 131 require I::Do::Not::Exist; 132 }, 133 PREREQ_FATAL => 1, 134 ); 135 }; 136 137 is $warnings, ''; 138 is $@, <<'END', "PREREQ_FATAL happens before CONFIGURE"; 139MakeMaker FATAL: prerequisites not found. 140 I::Do::Not::Exist not installed 141 142Please install these modules first and rerun 'perl Makefile.PL'. 143END 144 145} 146