From: Peter Rabbitson Date: Wed, 4 Nov 2015 16:25:11 +0000 (+0100) Subject: Work around RT#108460, intermittent postgresql-rename-table-and-field.t fail X-Git-Tag: v0.11022~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0b20d4687cc692b666734c4e44689daeafa0e78c;p=dbsrgits%2FSQL-Translator.git Work around RT#108460, intermittent postgresql-rename-table-and-field.t fail --- diff --git a/Changes b/Changes index 8681c21..49a2991 100644 --- a/Changes +++ b/Changes @@ -18,6 +18,7 @@ Changes for SQL::Translator * Fix identifier quoting in PostgreSQL diff producer * Fix missing semicolons between PostGIS statements * Fix string and identifier quoting in PostGIS statements + * Fix intermittent test failures (RT#108460) 0.11021 2015-01-29 diff --git a/t/postgresql-rename-table-and-field.t b/t/postgresql-rename-table-and-field.t index c6a0473..830fba9 100644 --- a/t/postgresql-rename-table-and-field.t +++ b/t/postgresql-rename-table-and-field.t @@ -11,16 +11,16 @@ use SQL::Translator::Diff; maybe_plan(undef, 'DBD::Pg'); -my ( $pgsql, $ddl, $ret, $dsn, $user, $pass ); +my ( $pg_tst, $ddl, $ret, $dsn, $user, $pass ); if ($ENV{DBICTEST_PG_DSN}) { ($dsn, $user, $pass) = map { $ENV{"DBICTEST_PG_$_"} } qw(DSN USER PASS); } else { no warnings 'once'; maybe_plan(undef, 'Test::PostgreSQL'); - $pgsql = Test::PostgreSQL->new + $pg_tst = Test::PostgreSQL->new or plan skip_all => "Can't create test database: $Test::PostgreSQL::errstr"; - $dsn = $pgsql->dsn; + $dsn = $pg_tst->dsn; }; my $dbh = DBI->connect($dsn, $user, $pass, { RaiseError => 1, AutoCommit => 1 }); @@ -80,12 +80,18 @@ cmp_ok( scalar(@$ret), '==', 1, "Got 1 row"); cmp_ok( $ret->[0]->{biff}, 'eq', 'buzz', "col biff has value buzz" ); # Make sure Test::PostgreSQL can kill Pg -undef $dbh if $pgsql; +undef $dbh if $pg_tst; END { - if ($dbh && !$pgsql) { + if ($dbh && !$pg_tst) { $dbh->do("drop table if exists sqlt_test_$_") foreach qw(foo fluff); } + elsif( $pg_tst ) { + # do the teardown ourselves, work around RT#108460 + local $?; + $pg_tst->stop; + 1; + } } done_testing;