-#!/usr/bin/perl -w
+package MakeMaker::Test::Setup::BFD;
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib';
- }
-}
-chdir 't';
+@ISA = qw(Exporter);
+require Exporter;
+@EXPORT = qw(setup_recurs teardown_recurs);
use strict;
-use Test::More tests => 9;
-use File::Basename;
use File::Path;
-use File::Spec;
-
-if( $^O eq 'VMS' ) {
- # On older systems we might exceed the 8-level directory depth limit
- # imposed by RMS. We get around this with a rooted logical, but we
- # can't create logical names with attributes in Perl, so we do it
- # in a DCL subprocess and put it in the job table so the parent sees it.
- open( BFDTMP, '>bfdtesttmp.com' ) || die "Error creating command file; $!";
- print BFDTMP <<'COMMAND';
-$ BFD_TEST_ROOT = F$PARSE("SYS$DISK:[-]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
-$ DEFINE/JOB/NOLOG/TRANSLATION=CONCEALED BFD_TEST_ROOT 'BFD_TEST_ROOT'
-COMMAND
- close BFDTMP;
-
- system '@bfdtesttmp.com';
- 1 while unlink 'bfdtesttmp.com';
-}
+use File::Basename;
my %Files = (
}
END
- 'Problem-Module/Makefile.PL' => <<'END',
-use ExtUtils::MakeMaker;
+ );
-WriteMakefile(
- NAME => 'Problem::Module',
-);
-END
- 'Problem-Module/subdir/Makefile.PL' => <<'END',
-printf "\@INC %s .\n", (grep { $_ eq '.' } @INC) ? "has" : "doesn't have";
+sub _setup_bfd_test_root {
+ if( $^O eq 'VMS' ) {
+ # On older systems we might exceed the 8-level directory depth limit
+ # imposed by RMS. We get around this with a rooted logical, but we
+ # can't create logical names with attributes in Perl, so we do it
+ # in a DCL subprocess and put it in the job table so the parent sees it.
+ open( BFDTMP, '>bfdtesttmp.com' ) ||
+ die "Error creating command file; $!";
+ print BFDTMP <<'COMMAND';
+$ BFD_TEST_ROOT = F$PARSE("SYS$DISK:[-]",,,,"NO_CONCEAL")-".][000000"-"]["-"].;"+".]"
+$ DEFINE/JOB/NOLOG/TRANSLATION=CONCEALED BFD_TEST_ROOT 'BFD_TEST_ROOT'
+COMMAND
+ close BFDTMP;
-warn "I think I'm going to be sick\n";
-die "YYYAaaaakkk\n";
-END
+ system '@bfdtesttmp.com';
+ 1 while unlink 'bfdtesttmp.com';
+ }
+}
- );
+sub setup_recurs {
+ _setup_bfd_test_root();
+
+ while(my($file, $text) = each %Files) {
+ # Convert to a relative, native file path.
+ $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file);
-while(my($file, $text) = each %Files) {
- # Convert to a relative, native file path.
- $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file);
+ my $dir = dirname($file);
+ mkpath $dir;
+ open(FILE, ">$file") || die "Can't create $file: $!";
+ print FILE $text;
+ close FILE;
+ }
- my $dir = dirname($file);
- mkpath $dir;
- open(FILE, ">$file");
- print FILE $text;
- close FILE;
+ return 1;
+}
- ok( -e $file, "$file created" );
+sub teardown_recurs {
+ foreach my $file (keys %Files) {
+ my $dir = dirname($file);
+ if( -e $dir ) {
+ rmtree($dir) || return;
+ }
+ }
+ return 1;
}
-pass("Setup done");
+1;