Commit | Line | Data |
---|---|---|
84a725ce JH |
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; | |
a7d1454b | 16 | use Test::More tests => 8; |
84a725ce | 17 | use MakeMaker::Test::Utils; |
a7d1454b | 18 | use MakeMaker::Test::Setup::BFD; |
84a725ce JH |
19 | use ExtUtils::MakeMaker; |
20 | use TieOut; | |
21 | ||
22 | chdir 't'; | |
23 | perl_lib; | |
24 | $| = 1; | |
25 | ||
26 | my $Makefile = makefile_name; | |
27 | ||
a7d1454b RGS |
28 | ok( setup_recurs(), 'setup' ); |
29 | END { | |
30 | ok( chdir File::Spec->updir ); | |
31 | ok( teardown_recurs(), 'teardown' ); | |
32 | } | |
33 | ||
84a725ce JH |
34 | ok( chdir 'Big-Dummy', q{chdir'd to Big-Dummy} ) || |
35 | diag("chdir failed: $!"); | |
36 | ||
37 | { | |
38 | my $warnings = ''; | |
39 | local $SIG{__WARN__} = sub { | |
40 | $warnings = join '', @_; | |
41 | }; | |
42 | ||
43 | my $stdout = tie *STDOUT, 'TieOut' or die; | |
44 | my $mm = WriteMakefile( | |
45 | NAME => 'Big::Dummy', | |
46 | VERSION_FROM => 'lib/Big/Dummy.pm', | |
47 | postamble => { | |
48 | FOO => 1, | |
49 | BAR => "fugawazads" | |
50 | } | |
51 | ); | |
52 | is( $warnings, '', 'postamble argument not warned about' ); | |
53 | } | |
54 | ||
55 | sub MY::postamble { | |
56 | my($self, %extra) = @_; | |
57 | ||
58 | is_deeply( \%extra, { FOO => 1, BAR => 'fugawazads' }, | |
59 | 'postamble args passed' ); | |
60 | ||
61 | return <<OUT; | |
62 | # This makes sure the postamble gets written | |
63 | OUT | |
64 | ||
65 | } | |
66 | ||
67 | ||
68 | ok( open(MAKEFILE, $Makefile) ) or diag "Can't open $Makefile: $!"; | |
69 | { local $/; | |
70 | like( <MAKEFILE>, qr/^\# This makes sure the postamble gets written\n/m, | |
71 | 'postamble added to the Makefile' ); | |
72 | } | |
dd0810f9 | 73 | close MAKEFILE; |