1#!/usr/bin/perl -w 2 3# Wherein we ensure that postamble works ok. 4 5BEGIN { 6 unshift @INC, 't/lib'; 7} 8 9use strict; 10use warnings; 11use Config; 12use Test::More tests => 8; 13use MakeMaker::Test::Utils; 14use MakeMaker::Test::Setup::BFD; 15use ExtUtils::MakeMaker; 16use TieOut; 17 18chdir 't'; 19perl_lib; # sets $ENV{PERL5LIB} relative to t/ 20 21use File::Temp qw[tempdir]; 22my $tmpdir = tempdir( DIR => '../t', CLEANUP => 1 ); 23use Cwd; my $cwd = getcwd; END { chdir $cwd } # so File::Temp can cleanup 24chdir $tmpdir; 25$| = 1; 26 27my $Makefile = makefile_name; 28 29ok( setup_recurs(), 'setup' ); 30END { 31 ok( chdir File::Spec->updir ); 32 ok( teardown_recurs(), 'teardown' ); 33} 34 35ok( chdir 'Big-Dummy', q{chdir'd to Big-Dummy} ) || 36 diag("chdir failed: $!"); 37 38{ 39 my $warnings = ''; 40 local $SIG{__WARN__} = sub { 41 if ( $Config{usecrosscompile} ) { 42 # libraries might not be present on the target system 43 # when cross-compiling 44 return if $_[0] =~ /\A\QWarning (mostly harmless): No library found for \E.+/ 45 } 46 $warnings = join '', @_; 47 }; 48 49 my $stdout = tie *STDOUT, 'TieOut' or die; 50 my $mm = WriteMakefile( 51 NAME => 'Big::Dummy', 52 VERSION_FROM => 'lib/Big/Dummy.pm', 53 postamble => { 54 FOO => 1, 55 BAR => "fugawazads" 56 } 57 ); 58 is( $warnings, '', 'postamble argument not warned about' ); 59} 60 61sub MY::postamble { 62 my($self, %extra) = @_; 63 64 is_deeply( \%extra, { FOO => 1, BAR => 'fugawazads' }, 65 'postamble args passed' ); 66 67 return <<OUT; 68# This makes sure the postamble gets written 69OUT 70 71} 72 73 74ok( open(MAKEFILE, $Makefile) ) or diag "Can't open $Makefile: $!"; 75{ local $/; 76 like( <MAKEFILE>, qr/^\# This makes sure the postamble gets written\n/m, 77 'postamble added to the Makefile' ); 78} 79close MAKEFILE; 80