2 # Copyright (C) 2007, Parrot Foundation.
4 # 01-create_directories.t
9 use Test::More tests => 6;
11 use File::Path qw( mkpath );
12 use File::Temp qw( tempdir );
14 use Parrot::Install qw(
17 use IO::CaptureOutput qw( capture );
20 my $tdir = tempdir( CLEANUP => 1 );
23 my @dirs = qw(foo/bar foo/bar/baz);
24 create_directories($tdir, { map { $_ => 1 } @dirs });
26 foreach my $d (@dirs) {
27 $dirs_seen++ if -d "$tdir$d";
29 is($dirs_seen, 2, 'got expected number of directories created');
33 my $tdir = tempdir( CLEANUP => 1 );
36 my @dirs = qw(foo/bar foo/bar/baz);
37 my @created = mkpath( [ "$tdir$dirs[0]" ], 0, 0777 );
38 ok( ( -d $created[0] ),
39 "one directory created before create_directories() is called" );
41 create_directories($tdir, { map { $_ => 1 } @dirs });
43 foreach my $d (@dirs) {
44 $dirs_seen++ if -d "$tdir$d";
47 "create_directories() handled case where one directory already existed" );
51 my $tdir = tempdir( CLEANUP => 1 );
54 my @dirs = qw(foo/bar foo/bar/baz);
55 my @created = mkpath( [ $tdir . 'foo' ], 0, 0777 );
56 ok( ( -d $created[0] ),
57 "one directory created before create_directories() is called" );
59 create_directories($tdir, { map { $_ => 1 } @dirs });
61 foreach my $d (@dirs) {
62 $dirs_seen++ if -d "$tdir$d";
65 "create_directories() handled case where one path partially existed" );
68 pass("Completed all tests in $0");
70 ################### DOCUMENTATION ###################
74 01-create_directories.t - test subroutines exported by C<Parrot::Install>
78 % prove t/tools/install/01-create_directories.t
82 The files in this directory test functionality used by
83 F<tools/dev/install_files.pl> and F<tools/dev/install_dev_files.pl> and
84 exported by F<lib/Parrot/Install.pm>.
88 James E Keenan and Timothy S Nelson
92 Parrot::Install, F<tools/dev/install_files.pl>, F<tools/dev/install_dev_files.pl>
98 # cperl-indent-level: 4
101 # vim: expandtab shiftwidth=4: