Commit | Line | Data |
bb4e9162 |
1 | #!/usr/bin/perl -w |
2 | |
3 | use strict; |
4 | use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; |
738349a8 |
5 | use MBTest tests => 8; |
bb4e9162 |
6 | |
738349a8 |
7 | use_ok 'Module::Build'; |
8 | ensure_blib('Module::Build'); |
9 | |
10 | use IO::File; |
7a827510 |
11 | my $tmp = MBTest->tmpdir; |
bb4e9162 |
12 | |
13 | use DistGen; |
14 | my $dist = DistGen->new( dir => $tmp ); |
15 | $dist->regen; |
16 | |
738349a8 |
17 | $dist->chdir_in; |
bb4e9162 |
18 | |
19 | |
bb4e9162 |
20 | |
bb4e9162 |
21 | my $mb = Module::Build->new_from_context; |
22 | my @files; |
23 | |
24 | { |
25 | # Make sure copy_if_modified() can handle spaces in filenames |
26 | |
27 | my @tmp; |
28 | foreach (1..2) { |
29 | my $tmp = File::Spec->catdir('t', "tmp$_"); |
30 | $mb->add_to_cleanup($tmp); |
31 | push @files, $tmp; |
32 | unless (-d $tmp) { |
33 | mkdir($tmp, 0777) or die "Can't create $tmp: $!"; |
34 | } |
35 | ok -d $tmp; |
36 | $tmp[$_] = $tmp; |
37 | } |
38 | |
39 | my $filename = 'file with spaces.txt'; |
40 | |
41 | my $file = File::Spec->catfile($tmp[1], $filename); |
42 | my $fh = IO::File->new($file, '>') or die "Can't create $file: $!"; |
43 | print $fh "Foo\n"; |
44 | $fh->close; |
45 | ok -e $file; |
46 | |
47 | |
48 | my $file2 = $mb->copy_if_modified(from => $file, to_dir => $tmp[2]); |
49 | ok $file2; |
50 | ok -e $file2; |
51 | } |
52 | |
53 | { |
54 | # Try some dir_contains() combinations |
55 | my $first = File::Spec->catdir('', 'one', 'two'); |
56 | my $second = File::Spec->catdir('', 'one', 'two', 'three'); |
57 | |
58 | ok( Module::Build->dir_contains($first, $second) ); |
59 | } |
60 | |
61 | # cleanup |
bb4e9162 |
62 | $dist->remove; |