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