Full initial pass at perldelta. ready for sanity checking
[p5sagit/p5-mst-13.2.git] / cpan / ExtUtils-MakeMaker / 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     unshift @INC, 't/lib';
8 }
9
10 use strict;
11 use Test::More tests => 13;
12
13 use TieOut;
14 use MakeMaker::Test::Utils;
15 use MakeMaker::Test::Setup::BFD;
16
17 use ExtUtils::MakeMaker;
18
19 chdir 't';
20
21 perl_lib();
22
23 ok( setup_recurs(), 'setup' );
24 END {
25     ok( chdir File::Spec->updir );
26     ok( teardown_recurs(), 'teardown' );
27 }
28
29 ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
30   diag("chdir failed: $!");
31
32 {
33     ok( my $stdout = tie *STDOUT, 'TieOut' );
34     my $warnings = '';
35     local $SIG{__WARN__} = sub {
36         $warnings .= join '', @_;
37     };
38
39     WriteMakefile(
40         NAME            => 'Big::Dummy',
41         PREREQ_PM       => {
42             strict  => 0
43         }
44     );
45     is $warnings, '';
46
47     $warnings = '';
48     WriteMakefile(
49         NAME            => 'Big::Dummy',
50         PREREQ_PM       => {
51             strict  => 99999
52         }
53     );
54     is $warnings, 
55     sprintf("Warning: prerequisite strict 99999 not found. We have %s.\n",
56             $strict::VERSION);
57
58     $warnings = '';
59     WriteMakefile(
60         NAME            => 'Big::Dummy',
61         PREREQ_PM       => {
62             "I::Do::Not::Exist" => 0,
63         }
64     );
65     is $warnings, 
66     "Warning: prerequisite I::Do::Not::Exist 0 not found.\n";
67
68     $warnings = '';
69     WriteMakefile(
70         NAME            => 'Big::Dummy',
71         PREREQ_PM       => {
72             "I::Do::Not::Exist" => 0,
73             "strict"            => 99999,
74         }
75     );
76     is $warnings, 
77     "Warning: prerequisite I::Do::Not::Exist 0 not found.\n".
78     sprintf("Warning: prerequisite strict 99999 not found. We have %s.\n",
79             $strict::VERSION);
80     
81     $warnings = '';
82     eval {
83         WriteMakefile(
84             NAME            => 'Big::Dummy',
85             PREREQ_PM       => {
86                 "I::Do::Not::Exist" => 0,
87                 "Nor::Do::I"        => 0,
88                 "strict"            => 99999,
89             },
90             PREREQ_FATAL    => 1,
91         );
92     };
93     
94     is $warnings, '';
95     is $@, <<'END', "PREREQ_FATAL";
96 MakeMaker FATAL: prerequisites not found.
97     I::Do::Not::Exist not installed
98     Nor::Do::I not installed
99     strict 99999
100
101 Please install these modules first and rerun 'perl Makefile.PL'.
102 END
103
104
105     $warnings = '';
106     eval {
107         WriteMakefile(
108             NAME            => 'Big::Dummy',
109             PREREQ_PM       => {
110                 "I::Do::Not::Exist" => 0,
111             },
112             CONFIGURE => sub {
113                 require I::Do::Not::Exist;
114             },
115             PREREQ_FATAL    => 1,
116         );
117     };
118     
119     is $warnings, '';
120     is $@, <<'END', "PREREQ_FATAL happens before CONFIGURE";
121 MakeMaker FATAL: prerequisites not found.
122     I::Do::Not::Exist not installed
123
124 Please install these modules first and rerun 'perl Makefile.PL'.
125 END
126
127 }