This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add add-package.pl to the core (was Re: Why no (XML|DBI|WWW|Template) modules in...
[perl5.git] / t / lib / MakeMaker / Test / Setup / Recurs.pm
CommitLineData
3377b245
JH
1package MakeMaker::Test::Setup::Recurs;
2
3@ISA = qw(Exporter);
4require Exporter;
5@EXPORT = qw(setup_recurs teardown_recurs);
6
7use strict;
8use File::Path;
9use File::Basename;
7292dc67 10use MakeMaker::Test::Utils;
3377b245
JH
11
12my %Files = (
13 'Recurs/Makefile.PL' => <<'END',
14use ExtUtils::MakeMaker;
15
16WriteMakefile(
17 NAME => 'Recurs',
18 VERSION => 1.00,
19);
20END
21
22 'Recurs/prj2/Makefile.PL' => <<'END',
23use ExtUtils::MakeMaker;
24
25WriteMakefile(
26 NAME => 'Recurs::prj2',
27 VERSION => 1.00,
28);
29END
30 );
31
32sub 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
50sub 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
611;