From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Date: Wed, 1 Apr 2015 17:52:22 +0000 (+0100)
Subject: Work around Firebird/InterBase/ODBC crash in tests
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dabde0bc5a737cedb57b2b4d74a73694044354e8;p=dbsrgits%2FDBIx-Class.git

Work around Firebird/InterBase/ODBC crash in tests

If DBD::Firebird and DBD::InterBase are used in the same process, the
last one loaded leaves an active statement handle around and later
segfaults at some point in the tests.  Also, if DBD::ODBC is used
before either of them, they leak the handle but don't segfault.

Thus, to avoid breaking installing DBIC if more than one of
DBICTEST_FIREBIRD(_INTERBASE|ODBC)?_DSN is set, skip Interbase if any
of the others are set, and make sure to run the ODBC test last.

However, keep the leak-triggering order for author, CI and smoker
runs, so we don't forget that it needs fixing.
---

diff --git a/t/750firebird.t b/t/750firebird.t
index d092379..1d06387 100644
--- a/t/750firebird.t
+++ b/t/750firebird.t
@@ -36,7 +36,12 @@ plan skip_all => join (' ',
 
 my $schema;
 
-for my $prefix (keys %$env2optdep) { SKIP: {
+my @test_order = map { "DBICTEST_FIREBIRD$_" }
+  DBICTest::RunMode->is_plain
+    ? ('', '_INTERBASE', '_ODBC')   # Least likely to fail
+    : ('_ODBC', '_INTERBASE' , ''); # Most likely to fail
+
+for my $prefix (@test_order) { SKIP: {
 
   my ($dsn, $user, $pass) = map { $ENV{"${prefix}_$_"} } qw/DSN USER PASS/;
 
@@ -47,6 +52,10 @@ for my $prefix (keys %$env2optdep) { SKIP: {
   skip ("Testing with ${prefix}_DSN needs " . DBIx::Class::Optional::Dependencies->req_missing_for( $env2optdep->{$prefix} ), 1)
     unless  DBIx::Class::Optional::Dependencies->req_ok_for($env2optdep->{$prefix});
 
+  skip ("DBD::InterBase crashes if Firebird or ODBC are also loaded", 1)
+    if $prefix eq 'DBICTEST_FIREBIRD_INTERBASE' and
+      ($ENV{DBICTEST_FIREBIRD_DSN} or $ENV{DBICTEST_FIREBIRD_ODBC_DSN});
+
   $schema = DBICTest::Schema->connect($dsn, $user, $pass, {
     auto_savepoint  => 1,
     quote_names     => 1,