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