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