Upgrade to ExtUtils::MakeMaker 6.16.
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / postamble.t
1 #!/usr/bin/perl -w
2
3 # Wherein we ensure that postamble works ok.
4
5 BEGIN {
6     if( $ENV{PERL_CORE} ) {
7         chdir 't' if -d 't';
8         @INC = ('../lib', 'lib');
9     }
10     else {
11         unshift @INC, 't/lib';
12     }
13 }
14
15 use strict;
16 use Test::More tests => 5;
17 use MakeMaker::Test::Utils;
18 use ExtUtils::MakeMaker;
19 use TieOut;
20
21 chdir 't';
22 perl_lib;
23 $| = 1;
24
25 my $Makefile = makefile_name;
26
27 ok( chdir 'Big-Dummy', q{chdir'd to Big-Dummy} ) ||
28         diag("chdir failed: $!");
29
30 {
31     my $warnings = '';
32     local $SIG{__WARN__} = sub {
33         $warnings = join '', @_;
34     };
35
36     my $stdout = tie *STDOUT, 'TieOut' or die;
37     my $mm = WriteMakefile(
38                            NAME            => 'Big::Dummy',
39                            VERSION_FROM    => 'lib/Big/Dummy.pm',
40                            postamble       => {
41                                                FOO => 1,
42                                                BAR => "fugawazads"
43                                               }
44                           );
45     is( $warnings, '', 'postamble argument not warned about' );
46 }
47
48 sub MY::postamble {
49     my($self, %extra) = @_;
50
51     is_deeply( \%extra, { FOO => 1, BAR => 'fugawazads' }, 
52                'postamble args passed' );
53
54     return <<OUT;
55 # This makes sure the postamble gets written
56 OUT
57
58 }
59
60
61 ok( open(MAKEFILE, $Makefile) ) or diag "Can't open $Makefile: $!";
62 { local $/; 
63   like( <MAKEFILE>, qr/^\# This makes sure the postamble gets written\n/m,
64         'postamble added to the Makefile' );
65 }