Commit | Line | Data |
---|---|---|
3377b245 JH |
1 | package MakeMaker::Test::Setup::Recurs; |
2 | ||
3 | @ISA = qw(Exporter); | |
4 | require Exporter; | |
5 | @EXPORT = qw(setup_recurs teardown_recurs); | |
6 | ||
7 | use strict; | |
8 | use File::Path; | |
9 | use File::Basename; | |
7292dc67 | 10 | use MakeMaker::Test::Utils; |
3377b245 JH |
11 | |
12 | my %Files = ( | |
13 | 'Recurs/Makefile.PL' => <<'END', | |
14 | use ExtUtils::MakeMaker; | |
15 | ||
16 | WriteMakefile( | |
17 | NAME => 'Recurs', | |
18 | VERSION => 1.00, | |
19 | ); | |
20 | END | |
21 | ||
22 | 'Recurs/prj2/Makefile.PL' => <<'END', | |
23 | use ExtUtils::MakeMaker; | |
24 | ||
25 | WriteMakefile( | |
26 | NAME => 'Recurs::prj2', | |
27 | VERSION => 1.00, | |
28 | ); | |
29 | END | |
30 | ); | |
31 | ||
32 | sub setup_recurs { | |
7292dc67 RGS |
33 | setup_mm_test_root(); |
34 | chdir 'MM_TEST_ROOT:[t]' if $^O eq 'VMS'; | |
35 | ||
3377b245 JH |
36 | while(my($file, $text) = each %Files) { |
37 | # Convert to a relative, native file path. | |
38 | $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file); | |
39 | ||
40 | my $dir = dirname($file); | |
41 | mkpath $dir; | |
42 | open(FILE, ">$file") || die "Can't create $file: $!"; | |
43 | print FILE $text; | |
44 | close FILE; | |
45 | } | |
46 | ||
47 | return 1; | |
48 | } | |
49 | ||
50 | sub teardown_recurs { | |
51 | foreach my $file (keys %Files) { | |
52 | my $dir = dirname($file); | |
53 | if( -e $dir ) { | |
54 | rmtree($dir) || return; | |
55 | } | |
56 | } | |
57 | return 1; | |
58 | } | |
a7d1454b RGS |
59 | |
60 | ||
61 | 1; |