Upgrade to ExtUtils-MakeMaker-6.36
[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     sprintf("Warning: prerequisite strict 99999 not found. We have %s.\n",
62             strict->VERSION);
63
64     $warnings = '';
65     WriteMakefile(
66         NAME            => 'Big::Dummy',
67         PREREQ_PM       => {
68             "I::Do::Not::Exist" => 0,
69         }
70     );
71     is $warnings, 
72     "Warning: prerequisite I::Do::Not::Exist 0 not found.\n";
73
74     $warnings = '';
75     WriteMakefile(
76         NAME            => 'Big::Dummy',
77         PREREQ_PM       => {
78             "I::Do::Not::Exist" => 0,
79             "strict"            => 99999,
80         }
81     );
82     is $warnings, 
83     "Warning: prerequisite I::Do::Not::Exist 0 not found.\n".
84     sprintf("Warning: prerequisite strict 99999 not found. We have %s.\n",
85             strict->VERSION);
86     
87     $warnings = '';
88     eval {
89         WriteMakefile(
90             NAME            => 'Big::Dummy',
91             PREREQ_PM       => {
92                 "I::Do::Not::Exist" => 0,
93                 "Nor::Do::I"        => 0,
94                 "strict"            => 99999,
95             },
96             PREREQ_FATAL    => 1,
97         );
98     };
99     
100     is $warnings, '';
101     is $@, <<'END', "PREREQ_FATAL";
102 MakeMaker FATAL: prerequisites not found.
103     I::Do::Not::Exist not installed
104     Nor::Do::I not installed
105     strict 99999
106
107 Please install these modules first and rerun 'perl Makefile.PL'.
108 END
109
110 }