This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to ExtUtils::MakeMaker 6.52
[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
277189c8
SP
30
31 # Check if a test failure in a subdir causes make test to fail
32 'Recurs/prj2/t/fail.t' => <<'END',
33#!/usr/bin/perl -w
34
35print "1..1\n";
36print "not ok 1\n";
37END
3377b245
JH
38 );
39
40sub setup_recurs {
7292dc67
RGS
41 setup_mm_test_root();
42 chdir 'MM_TEST_ROOT:[t]' if $^O eq 'VMS';
43
3377b245
JH
44 while(my($file, $text) = each %Files) {
45 # Convert to a relative, native file path.
46 $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file);
47
48 my $dir = dirname($file);
49 mkpath $dir;
50 open(FILE, ">$file") || die "Can't create $file: $!";
51 print FILE $text;
52 close FILE;
5bdf71cc
RGS
53
54 # ensure file at least 1 second old for makes that assume
55 # files with the same time are out of date.
56 my $time = calibrate_mtime();
57 utime $time, $time - 1, $file;
3377b245
JH
58 }
59
60 return 1;
61}
62
63sub teardown_recurs {
64 foreach my $file (keys %Files) {
65 my $dir = dirname($file);
66 if( -e $dir ) {
67 rmtree($dir) || return;
68 }
69 }
70 return 1;
71}
a7d1454b
RGS
72
73
741;