Upgrade to Module-Build-0.30
[p5sagit/p5-mst-13.2.git] / lib / Module / Build / t / files.t
CommitLineData
bb4e9162 1#!/usr/bin/perl -w
2
3use strict;
4use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
738349a8 5use MBTest tests => 8;
bb4e9162 6
738349a8 7use_ok 'Module::Build';
8ensure_blib('Module::Build');
9
10use IO::File;
7a827510 11my $tmp = MBTest->tmpdir;
bb4e9162 12
13use DistGen;
14my $dist = DistGen->new( dir => $tmp );
15$dist->regen;
16
738349a8 17$dist->chdir_in;
bb4e9162 18
19
bb4e9162 20
bb4e9162 21my $mb = Module::Build->new_from_context;
22my @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;