1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#!/usr/bin/perl
use strict;
use warnings;
use Config;
use File::Path qw( rmtree );
use Test::More ( tests => 15 );
use ExtUtils::MakeMaker;
my $FILE = 'test-Makefile';
rmtree( [ qw( tlib troot ) ], 0, 0 );
END {
$FILE and -f $FILE and unlink $FILE;
rmtree( [ qw( tlib troot ) ], 0, 0 );
}
use File::ShareDir::Install;
install_share 't/share';
install_share module => 'My::Test' => 't/module';
delete $ENV{PERL_MM_OPT}; # local::lib + PREFIX below will FAIL
# XXX maybe we should just remove INSTALL_BASE=[^ ]+ from PERL_MM_OPT?
WriteMakefile(
NAME => 'File::ShareDir::Install',
VERSION_FROM => 'lib/File/ShareDir/Install.pm',
INST_LIB => 'tlib/lib',
PREFIX => 'troot',
MAKEFILE => $FILE,
PREREQ_PM => {},
($] >= 5.005 ?
(ABSTRACT_FROM => 'lib/File/ShareDir/Install.pm',
AUTHOR => 'Philip Gwyn <fil@localdomain>') : ()),
);
sub slurp
{
local @ARGV = @_;
local $/;
local $.;
<>;
};
#####
ok( -f $FILE, "Created $FILE" );
my $content = slurp $FILE;
ok( $content =~ m(t.share.honk.+share.dist...DISTNAME..honk), "Shared by dist" );
ok( $content =~ m(t.module.bonk.+share.module.My-Test.bonk), "Shared by module" );
ok( $content =~ m(t.module.again.+share.module.My-Test.again), "Shared by module again" );
ok( $content =~ m(t.module.deeper.bonk.+share.module.My-Test.deeper.bonk), "Shared by module in subdirectory" );
#####
mysystem( $Config{make}, '-f', $FILE );
my $TOP = "tlib/lib/auto/share";
ok( -f "$TOP/dist/File-ShareDir-Install/honk", "Copied to blib for dist" );
ok( -f "$TOP/module/My-Test/bonk", "Copied to blib for module" );
ok( -f "$TOP/module/My-Test/again", "Copied to blib for module again" );
ok( -f "$TOP/module/My-Test/deeper/bonk", "Copied to blib for module, in subdir" );
my $c = slurp "$TOP/module/My-Test/bonk";
is( $c, "bonk\n", "Same names" );
$c = slurp "$TOP/module/My-Test/deeper/bonk";
is( $c, "deeper\n", " ... not mixed up" );
#####
mysystem( $Config{make}, '-f', $FILE, 'install' );
unless( $content =~ m(INSTALLSITELIB = (.+)) ) {
SKIP: {
skip "Can't find INSTALLSITELIB in test-Makefile", 4;
}
}
else {
$TOP = "$1/auto/share";
$TOP =~ s/\$\(SITEPREFIX\)/troot/;
ok( -f "$TOP/dist/File-ShareDir-Install/honk", "Copied to blib for dist" );
ok( -f "$TOP/module/My-Test/bonk", "Copied to blib for module" );
ok( -f "$TOP/module/My-Test/again", "Copied to blib for module again" );
ok( -f "$TOP/module/My-Test/deeper/bonk", "Copied to blib for module, in subdir" );
}
#####################################
sub mysystem
{
my $cmd = join ' ', @_;
my $ret = qx($cmd 2>&1);
return unless $?;
die "Error running $cmd: ?=$? ret=$ret";
}
###########################################################################
package MY;
use File::ShareDir::Install qw(postamble);
|