ExtUtils::MakeMaker 6.55_02
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / pm_to_blib.t
1 #!/usr/bin/perl -w
2
3 # Ensure pm_to_blib runs at the right times.
4
5 BEGIN {
6     if ($ENV{PERL_CORE}) {
7         chdir 't' if -d 't';
8         @INC = qw(../lib lib);
9     }
10 }
11
12 use strict;
13 use lib 't/lib';
14
15 use Test::More 'no_plan';
16
17 use ExtUtils::MakeMaker;
18
19 use MakeMaker::Test::Utils;
20 use MakeMaker::Test::Setup::BFD;
21
22
23 my $perl     = which_perl();
24 my $makefile = makefile_name();
25 my $make     = make_run();
26
27
28 # Setup our test environment
29 {
30     chdir 't';
31
32     perl_lib;
33
34     ok( setup_recurs(), 'setup' );
35     END {
36         ok( chdir File::Spec->updir );
37         ok( teardown_recurs(), 'teardown' );
38     }
39
40     ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) ||
41       diag("chdir failed: $!");
42 }
43
44
45 # Run make once
46 {
47     run_ok(qq{$perl Makefile.PL});
48     run_ok($make);
49
50     ok( -e "blib/lib/Big/Dummy.pm", "blib copied pm file" );
51 }
52
53
54 # Change a pm file, it should be copied.
55 {
56     # Wait a couple seconds else our changed file will have the same timestamp
57     # as the blib file
58     sleep 2;
59
60     ok( open my $fh, ">>", "lib/Big/Dummy.pm" ) or die $!;
61     print $fh "Something else\n";
62     close $fh;
63
64     run_ok($make);
65     like slurp("blib/lib/Big/Dummy.pm"), qr/Something else\n$/;
66 }
67
68
69 # Rerun the Makefile.PL, pm_to_blib should rerun
70 {
71     run_ok(qq{$perl Makefile.PL});
72
73     # XXX This is a fragile way to check that it reran.
74     like run_ok($make), qr/^Skip /ms;
75
76     ok( -e "blib/lib/Big/Dummy.pm", "blib copied pm file" );
77 }