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'; |
5 | use MBTest tests => 6; |
6 | |
7 | use Cwd (); |
8 | my $cwd = Cwd::cwd; |
9 | my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' ); |
10 | |
11 | use DistGen; |
12 | my $dist = DistGen->new( dir => $tmp ); |
13 | $dist->regen; |
14 | |
15 | chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; |
16 | |
17 | |
18 | use IO::File; |
19 | |
20 | |
21 | use Module::Build; |
22 | my $mb = Module::Build->new_from_context; |
23 | my @files; |
24 | |
25 | { |
26 | # Make sure copy_if_modified() can handle spaces in filenames |
27 | |
28 | my @tmp; |
29 | foreach (1..2) { |
30 | my $tmp = File::Spec->catdir('t', "tmp$_"); |
31 | $mb->add_to_cleanup($tmp); |
32 | push @files, $tmp; |
33 | unless (-d $tmp) { |
34 | mkdir($tmp, 0777) or die "Can't create $tmp: $!"; |
35 | } |
36 | ok -d $tmp; |
37 | $tmp[$_] = $tmp; |
38 | } |
39 | |
40 | my $filename = 'file with spaces.txt'; |
41 | |
42 | my $file = File::Spec->catfile($tmp[1], $filename); |
43 | my $fh = IO::File->new($file, '>') or die "Can't create $file: $!"; |
44 | print $fh "Foo\n"; |
45 | $fh->close; |
46 | ok -e $file; |
47 | |
48 | |
49 | my $file2 = $mb->copy_if_modified(from => $file, to_dir => $tmp[2]); |
50 | ok $file2; |
51 | ok -e $file2; |
52 | } |
53 | |
54 | { |
55 | # Try some dir_contains() combinations |
56 | my $first = File::Spec->catdir('', 'one', 'two'); |
57 | my $second = File::Spec->catdir('', 'one', 'two', 'three'); |
58 | |
59 | ok( Module::Build->dir_contains($first, $second) ); |
60 | } |
61 | |
62 | # cleanup |
63 | chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; |
64 | $dist->remove; |
65 | |
66 | use File::Path; |
67 | rmtree( $tmp ); |