Skip to content

Commit 851a762

Browse files
demerphqbingos
authored andcommitted
use a poor mans tempdir logic for parallel tests
In core we want to run the tests in parallel. The tests in EUMM are not parallel safe as they all use the same directory for BFD and then the teardown from one affects the other, etc. This adds a poor mans temporary directory so each test invocation gets its own copy of the BFD directory. This has been tested in core builds already, and migrated to the master repo for EUMM from there.
1 parent 6409190 commit 851a762

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

t/INST.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ is( !!$mm->{PERL_CORE}, !!$ENV{PERL_CORE}, 'PERL_CORE' );
7676

7777
my($perl_src, $mm_perl_src);
7878
if( $ENV{PERL_CORE} ) {
79-
$perl_src = File::Spec->catdir($Updir, $Updir, $Updir, $Updir, $Updir);
79+
$perl_src = File::Spec->catdir($Updir, $Updir, $Updir, $Updir, $Updir, $Updir);
8080
$perl_src = File::Spec->canonpath($perl_src);
8181
$mm_perl_src = File::Spec->canonpath($mm->{PERL_SRC});
8282
}
8383
else {
8484
$mm_perl_src = $mm->{PERL_SRC};
8585
}
8686

87-
is( $mm_perl_src, $perl_src, 'PERL_SRC' );
87+
is( $mm_perl_src, $perl_src, "PERL_SRC" );
8888

8989

9090
# PERM_*

t/INST_PREFIX.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ is( !!$mm->{PERL_CORE}, !!$ENV{PERL_CORE}, 'PERL_CORE' );
109109

110110
my($perl_src, $mm_perl_src);
111111
if( $ENV{PERL_CORE} ) {
112-
$perl_src = File::Spec->catdir($Updir, $Updir, $Updir, $Updir, $Updir);
112+
$perl_src = File::Spec->catdir($Updir, $Updir, $Updir, $Updir, $Updir, $Updir);
113113
$perl_src = File::Spec->canonpath($perl_src);
114114
$mm_perl_src = File::Spec->canonpath($mm->{PERL_SRC});
115115
}

t/lib/MakeMaker/Test/Setup/BFD.pm

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,20 @@ END
103103

104104
);
105105

106+
my $tmpdir;
106107

107108
# if given args, those are inserted as components in resulting path, eg:
108109
# setup_recurs('dir') means instead of creating Big-Dummy/*, dir/Big-Dummy/*
109110
sub setup_recurs {
110-
while(my($file, $text) = each %Files) {
111+
my @chrs=("A".."Z",0-9);
112+
# annoyingly we cant use File::Temp here as it drags in XS code
113+
# and we run under blocks to prevent XS code loads. This is a minimal
114+
# patch to fix the issue.
115+
$tmpdir = join "", "./temp-$$-", map { $chrs[rand(@chrs)] } 1..8;
116+
mkdir($tmpdir) or die "Failed to create '$tmpdir': $!";
117+
chdir($tmpdir) or die "Failed to chdir '$tmpdir': $!";
118+
foreach my $file (sort keys %Files) {
119+
my $text = $Files{$file};
111120
# Convert to a relative, native file path.
112121
$file = File::Spec->catfile(File::Spec->curdir, @_, split m{\/}, $file);
113122
$file = File::Spec->rel2abs($file);
@@ -131,9 +140,11 @@ sub teardown_recurs {
131140
foreach my $file (keys %Files) {
132141
my $dir = dirname($file);
133142
if( -e $dir ) {
134-
rmtree($dir) || return;
143+
rmtree($dir) or next;
135144
}
136145
}
146+
chdir("..");
147+
rmtree($tmpdir);
137148
return 1;
138149
}
139150

0 commit comments

Comments
 (0)