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
|
#!/usr/bin/perl -w
use strict;
use lib 't/lib';
use MBTest tests => 8;
use DistGen;
use Module::Build;
my $dist;
# Test that PL files don't get installed even in bin or lib
{
$dist = DistGen->new( dir => MBTest->tmpdir );
$dist->regen;
$dist->chdir_in;
my $distname = $dist->name;
$dist->change_build_pl({
module_name => $distname,
PL_files => {
'bin/foo.PL' => 'bin/foo',
'lib/Bar.pm.PL' => 'lib/Bar.pm',
},
});
$dist->add_file("bin/foo.PL", <<'END');
open my $fh, ">", $ARGV[0] or die $!;
print $fh "foo\n";
END
$dist->add_file("lib/Bar.pm.PL", <<'END');
open my $fh, ">", $ARGV[0] or die $!;
print $fh "bar\n";
END
$dist->regen;
my $mb = Module::Build->new_from_context( install_base => "test_install" );
$mb->dispatch("install");
ok -e "test_install/bin/foo", "Generated PL_files installed from bin";
ok -e "test_install/lib/perl5/Bar.pm", " and from lib";
ok !-e "test_install/bin/foo.PL", "PL_files not installed from bin";
ok !-e "test_install/lib/perl5/Bar.pm.PL", " nor from lib";
is slurp("test_install/bin/foo"), "foo\n", "Generated bin contains correct content";
is slurp("test_install/lib/perl5/Bar.pm"), "bar\n", " so does the lib";
$dist->chdir_original if $dist->did_chdir;
}
# Test an empty PL target list runs the PL but doesn't
# add it to MANIFEST or cleanup
{
$dist = DistGen->new( dir => MBTest->tmpdir );
$dist->regen;
$dist->chdir_in;
my $distname = $dist->name;
$dist->change_build_pl({
module_name => $distname,
PL_files => {
'Special.PL' => [],
},
});
$dist->add_file("Special.PL", <<'END');
open my $fh, ">", "foo" or die $!;
print $fh "foo\n";
END
$dist->regen;
my $mb = Module::Build->new_from_context();
$mb->dispatch("code");
ok( -f "foo", "special PL file ran" );
my $cleanup = $mb->cleanup;
my %cleanup = map { $_ => 1 } $mb->cleanup;
is($cleanup{foo}, undef, "generated special file not added to cleanup");
$dist->chdir_original if $dist->did_chdir;
}
|