forked from hdp/module-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extend.t
68 lines (53 loc) · 1.57 KB
/
extend.t
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
use strict;
use Test;
BEGIN { plan tests => 11 }
use Module::Build;
ok 1;
my $start_dir = Module::Build->cwd;
my $goto = File::Spec->catdir( $start_dir, 't', 'Sample' );
chdir $goto or die "can't chdir to $goto: $!";
# Here we make sure actions are only called once per dispatch()
$::x = 0;
my $build = Module::Build->subclass
(
code => "sub ACTION_loop { die 'recursed' if \$::x++; shift->depends_on('loop'); }"
)->new( module_name => 'Sample' );
ok $build;
$build->dispatch('loop');
ok $::x, 1;
$build->dispatch('realclean');
{
# Make sure globbing works in filenames
$build->test_files('*t*');
my $files = $build->test_files;
ok grep {$_ eq 'script'} @$files;
ok grep {$_ eq 'test.pl'} @$files;
ok !grep {$_ eq 'Build.PL'} @$files;
# Make sure order is preserved
$build->test_files('foo', 'bar');
$files = $build->test_files;
ok @$files, 2;
ok $files->[0], 'foo';
ok $files->[1], 'bar';
}
{
# Make sure we can add new kinds of stuff to the build sequence
{
package FooTester;
@FooTester::ISA = qw(Module::Build);
sub process_foo_files {
my $self = shift;
my $files = $self->_find_file_by_type('foo', File::Spec->curdir);
while (my ($file, $dest) = each %$files) {
$self->copy_if_modified(from => $file,
to => File::Spec->catfile($self->blib, 'lib', $dest) );
}
}
}
my $build = FooTester->new( module_name => 'Sample' );
ok $build;
$build->add_build_element('foo');
$build->dispatch('build');
ok -e File::Spec->catfile($build->blib, 'lib', 'test.foo');
$build->dispatch('realclean');
}