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