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