This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove MM_TEST_ROOT feature from ExtUtils::Install tests.
[perl5.git] / dist / ExtUtils-Install / t / lib / MakeMaker / Test / Setup / BFD.pm
1 package MakeMaker::Test::Setup::BFD;
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;
10 use MakeMaker::Test::Utils;
11
12 my %Files = (
13              'Big-Dummy/lib/Big/Dummy.pm'     => <<'END',
14 package Big::Dummy;
15
16 $VERSION = 0.02;
17
18 =head1 NAME
19
20 Big::Dummy - Try "our" hot dog's
21
22 =cut
23
24 1;
25 END
26
27              'Big-Dummy/Makefile.PL'          => <<'END',
28 use ExtUtils::MakeMaker;
29
30 # This will interfere with the PREREQ_PRINT tests.
31 printf "Current package is: %s\n", __PACKAGE__ unless "@ARGV" =~ /PREREQ/;
32
33 WriteMakefile(
34     NAME          => 'Big::Dummy',
35     VERSION_FROM  => 'lib/Big/Dummy.pm',
36     EXE_FILES     => [qw(bin/program)],
37     PREREQ_PM     => { strict => 0 },
38     ABSTRACT_FROM => 'lib/Big/Dummy.pm',
39     AUTHOR        => 'Michael G Schwern <schwern@pobox.com>',
40 );
41 END
42
43              'Big-Dummy/bin/program'          => <<'END',
44 #!/usr/bin/perl -w
45
46 =head1 NAME
47
48 program - this is a program
49
50 =cut
51
52 1;
53 END
54
55              'Big-Dummy/t/compile.t'          => <<'END',
56 print "1..2\n";
57
58 print eval "use Big::Dummy; 1;" ? "ok 1\n" : "not ok 1\n";
59 print "ok 2 - TEST_VERBOSE\n";
60 END
61
62              'Big-Dummy/Liar/t/sanity.t'      => <<'END',
63 print "1..3\n";
64
65 print eval "use Big::Dummy; 1;" ? "ok 1\n" : "not ok 1\n";
66 print eval "use Big::Liar; 1;" ? "ok 2\n" : "not ok 2\n";
67 print "ok 3 - TEST_VERBOSE\n";
68 END
69
70              'Big-Dummy/Liar/lib/Big/Liar.pm' => <<'END',
71 package Big::Liar;
72
73 $VERSION = 0.01;
74
75 1;
76 END
77
78              'Big-Dummy/Liar/Makefile.PL'     => <<'END',
79 use ExtUtils::MakeMaker;
80
81 my $mm = WriteMakefile(
82               NAME => 'Big::Liar',
83               VERSION_FROM => 'lib/Big/Liar.pm',
84               _KEEP_AFTER_FLUSH => 1
85              );
86
87 print "Big::Liar's vars\n";
88 foreach my $key (qw(INST_LIB INST_ARCHLIB)) {
89     print "$key = $mm->{$key}\n";
90 }
91 END
92
93             );
94
95
96 sub setup_recurs {
97
98     while(my($file, $text) = each %Files) {
99         # Convert to a relative, native file path.
100         $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file);
101
102         my $dir = dirname($file);
103         mkpath $dir;
104         open(FILE, ">$file") || die "Can't create $file: $!";
105         print FILE $text;
106         close FILE;
107
108         # ensure file at least 1 second old for makes that assume
109         # files with the same time are out of date.
110         my $time = calibrate_mtime();
111         utime $time, $time - 1, $file;
112     }
113
114     return 1;
115 }
116
117 sub teardown_recurs { 
118     foreach my $file (keys %Files) {
119         my $dir = dirname($file);
120         if( -e $dir ) {
121             rmtree($dir) || return;
122         }
123     }
124     return 1;
125 }
126
127
128 1;