This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to MakeMaker 6.20.
[perl5.git] / lib / ExtUtils / t / postamble.t
CommitLineData
84a725ce
JH
1#!/usr/bin/perl -w
2
3# Wherein we ensure that postamble works ok.
4
5BEGIN {
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
15use strict;
a7d1454b 16use Test::More tests => 8;
84a725ce 17use MakeMaker::Test::Utils;
a7d1454b 18use MakeMaker::Test::Setup::BFD;
84a725ce
JH
19use ExtUtils::MakeMaker;
20use TieOut;
21
22chdir 't';
23perl_lib;
24$| = 1;
25
26my $Makefile = makefile_name;
27
a7d1454b
RGS
28ok( setup_recurs(), 'setup' );
29END {
30 ok( chdir File::Spec->updir );
31 ok( teardown_recurs(), 'teardown' );
32}
33
84a725ce
JH
34ok( 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
55sub 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
63OUT
64
65}
66
67
68ok( 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 73close MAKEFILE;