Upgrade to ExtUtils-MakeMaker-6.35
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / prereq.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 'no_plan';
18
19 use TieOut;
20 use MakeMaker::Test::Utils;
21 use MakeMaker::Test::Setup::BFD;
22
23 use ExtUtils::MakeMaker;
24
25 chdir 't';
26
27 perl_lib();
28
29 ok( setup_recurs(), 'setup' );
30 END {
31     ok( chdir File::Spec->updir );
32     ok( teardown_recurs(), 'teardown' );
33 }
34
35 ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
36   diag("chdir failed: $!");
37
38 {
39     ok( my $stdout = tie *STDOUT, 'TieOut' );
40     my $warnings = '';
41     local $SIG{__WARN__} = sub {
42         $warnings .= join '', @_;
43     };
44
45     WriteMakefile(
46         NAME            => 'Big::Dummy',
47         PREREQ_PM       => {
48             strict  => 0
49         }
50     );
51     is $warnings, '';
52
53     $warnings = '';
54     WriteMakefile(
55         NAME            => 'Big::Dummy',
56         PREREQ_PM       => {
57             strict  => 99999
58         }
59     );
60     is $warnings, 
61     "Warning: prerequisite strict 99999 not found. We have $strict::VERSION.\n";
62
63     $warnings = '';
64     WriteMakefile(
65         NAME            => 'Big::Dummy',
66         PREREQ_PM       => {
67             "I::Do::Not::Exist" => 0,
68         }
69     );
70     is $warnings, 
71     "Warning: prerequisite I::Do::Not::Exist 0 not found.\n";
72
73     $warnings = '';
74     WriteMakefile(
75         NAME            => 'Big::Dummy',
76         PREREQ_PM       => {
77             "I::Do::Not::Exist" => 0,
78             "strict"            => 99999,
79         }
80     );
81     is $warnings, 
82     "Warning: prerequisite I::Do::Not::Exist 0 not found.\n".
83     "Warning: prerequisite strict 99999 not found. We have $strict::VERSION.\n";
84
85     
86     $warnings = '';
87     eval {
88         WriteMakefile(
89             NAME            => 'Big::Dummy',
90             PREREQ_PM       => {
91                 "I::Do::Not::Exist" => 0,
92                 "Nor::Do::I"        => 0,
93                 "strict"            => 99999,
94             },
95             PREREQ_FATAL    => 1,
96         );
97     };
98     
99     is $warnings, '';
100     is $@, <<'END', "PREREQ_FATAL";
101 MakeMaker FATAL: prerequisites not found.
102     I::Do::Not::Exist not installed
103     Nor::Do::I not installed
104     strict 99999
105
106 Please install these modules first and rerun 'perl Makefile.PL'.
107 END
108
109 }