This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move Module::Build from ext/ to cpan/
[perl5.git] / cpan / Module-Build / t / files.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use lib 't/lib';
5 use MBTest tests => 6;
6
7 use_ok 'Module::Build';
8 ensure_blib('Module::Build');
9
10 use IO::File;
11 my $tmp = MBTest->tmpdir;
12
13 use DistGen;
14 my $dist = DistGen->new( dir => $tmp );
15 $dist->regen;
16
17 $dist->chdir_in;
18
19 my $mb = Module::Build->new_from_context;
20
21 {
22   # Make sure copy_if_modified() can handle spaces in filenames
23   
24   my @tmp;
25   push @tmp, MBTest->tmpdir for (0 .. 1);
26   
27   my $filename = 'file with spaces.txt';
28   
29   my $file = File::Spec->catfile($tmp[0], $filename);
30   my $fh = IO::File->new($file, '>') or die "Can't create $file: $!";
31   print $fh "Foo\n";
32   $fh->close;
33   ok -e $file;
34   
35   
36   my $file2 = $mb->copy_if_modified(from => $file, to_dir => $tmp[1]);
37   ok $file2;
38   ok -e $file2;
39 }
40
41 {
42   # Try some dir_contains() combinations
43   my $first  = File::Spec->catdir('', 'one', 'two');
44   my $second = File::Spec->catdir('', 'one', 'two', 'three');
45   
46   ok( Module::Build->dir_contains($first, $second) );
47 }
48
49 # cleanup
50 $dist->remove;