[perl-ExtUtils-Depends/parallel-testing] Allow parellel testing
- From: Florian Ragwitz <rafl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-ExtUtils-Depends/parallel-testing] Allow parellel testing
- Date: Tue, 23 Nov 2010 03:02:22 +0000 (UTC)
commit f8f24ce375059182370c8ad2ec482b04b6906a5f
Author: Florian Ragwitz <rafl debian org>
Date: Mon Nov 22 02:53:12 2010 +0100
Allow parellel testing
All tests relied on the same files in t/inc, causing races when being run in
parallel.
t/02_save_load.t | 15 +++++++++------
t/03_deps.t | 13 ++++++++-----
t/04_extra_libs.t | 11 ++++++++---
t/lib/TestHelper.pm | 21 +++++++++++++++++++++
4 files changed, 46 insertions(+), 14 deletions(-)
---
diff --git a/t/02_save_load.t b/t/02_save_load.t
index b08010f..9d50572 100644
--- a/t/02_save_load.t
+++ b/t/02_save_load.t
@@ -3,8 +3,15 @@ use strict;
use warnings;
use Test::More tests => 24;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use TestHelper;
+
use ExtUtils::Depends;
+my $tmp_inc = temp_inc;
+
my $dep_info = ExtUtils::Depends->new ('DepTest');
my $inc = '-Iinclude -I/usr/local/include -W -Wall -Werror -ansi';
@@ -33,7 +40,7 @@ my @installed_files = qw(dep.h
dep-private.h);
$dep_info->install (@installed_files);
-$dep_info->save_config ('t/inc/DepTest/Install/Files.pm');
+$dep_info->save_config (catfile $tmp_inc, qw(DepTest Install Files.pm));
# --------------------------------------------------------------------------- #
@@ -46,7 +53,7 @@ foreach my $pm (keys %pm_mapping) {
like ($vars{PM}{$pm}, qr/\Q$pm_mapping{$pm}\E/);
}
-ok (exists $vars{PM}{'t/inc/DepTest/Install/Files.pm'});
+ok (exists $vars{PM}{catfile $tmp_inc, qw(DepTest Install Files.pm)});
foreach my $file (@installed_files) {
like ($vars{PM}{$file}, qr/\Q$file\E/);
@@ -64,8 +71,6 @@ foreach my $file (@c_files, @xs_files) {
# --------------------------------------------------------------------------- #
-use lib qw(t/inc);
-
my $info = ExtUtils::Depends::load ('DepTest');
my $install_part = qr|DepTest.Install|;
@@ -81,5 +86,3 @@ is_deeply ($info->{deps}, []);
is ($info->{libs}, $libs);
# --------------------------------------------------------------------------- #
-
-unlink 't/inc/DepTest/Install/Files.pm';
diff --git a/t/03_deps.t b/t/03_deps.t
index 51e9566..573f816 100644
--- a/t/03_deps.t
+++ b/t/03_deps.t
@@ -3,15 +3,20 @@ use strict;
use warnings;
use Test::More tests => 2;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use TestHelper;
+
use ExtUtils::Depends;
+my $tmp_inc = temp_inc;
+
my $dep_info = ExtUtils::Depends->new ('DepTest');
-$dep_info->save_config ('t/inc/DepTest/Install/Files.pm');
+$dep_info->save_config (catfile $tmp_inc, qw(DepTest Install Files.pm));
# --------------------------------------------------------------------------- #
-use lib qw(t/inc);
-
my $info = ExtUtils::Depends->new ('UseTest', 'DepTest');
my %deps = $info->get_deps;
@@ -27,5 +32,3 @@ $info->load_deps;
ok (exists $deps{DepTest});
# --------------------------------------------------------------------------- #
-
-unlink 't/inc/DepTest/Install/Files.pm';
diff --git a/t/04_extra_libs.t b/t/04_extra_libs.t
index 90700f4..1cdc059 100644
--- a/t/04_extra_libs.t
+++ b/t/04_extra_libs.t
@@ -3,14 +3,21 @@ use strict;
use warnings;
use Test::More;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+use TestHelper;
+
use ExtUtils::Depends;
+my $tmp_inc = temp_inc;
+
plan (($^O eq 'MSWin32' || $^O eq 'cygwin') ?
(tests => 1) :
(skip_all => 'test only applicable to MSWin32 and cygwin'));
my $dep_info = ExtUtils::Depends->new ('DepTest');
-$dep_info->save_config ('t/inc/DepTest/Install/Files.pm');
+$dep_info->save_config (catfile $tmp_inc, qw(DepTest Install Files.pm));
# --------------------------------------------------------------------------- #
@@ -22,5 +29,3 @@ my %vars = $use_info->get_makefile_vars;
like ($vars{LIBS}, qr/DepTest/);
# --------------------------------------------------------------------------- #
-
-unlink 't/inc/DepTest/Install/Files.pm';
diff --git a/t/lib/TestHelper.pm b/t/lib/TestHelper.pm
new file mode 100644
index 0000000..884dbf0
--- /dev/null
+++ b/t/lib/TestHelper.pm
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+package TestHelper;
+
+use File::Temp 'tempdir';
+use File::Path 'mkpath';
+use File::Spec::Functions 'catdir', 'catfile';
+
+use base 'Exporter';
+
+our @EXPORT = ('temp_inc', 'catfile');
+
+sub temp_inc {
+ my $tmpinc = tempdir(CLEANUP => 1);
+ mkpath(catdir($tmpinc, qw(DepTest Install)), 0, 0711);
+ unshift @INC, $tmpinc;
+ return $tmpinc;
+}
+
+1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]