From 04986dab93539b562c832bbd7dba03a55b6d049c Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Wed, 1 Aug 2018 00:19:10 -0700 Subject: [PATCH] Introduce MediaWikiTestCase::markTestSkippedIfDbType() Helper to skip tests if they're being run with a specific DBMS where the test currently fails. The main use case for this is to temporarily disable failing postgres and sqlite tests so we can make those test runs voting (so we don't regress any further), and re-enable the tests once they've been fixed. Change-Id: I1fd7ca6b2d21fed59ed387376d03489c7cbccdfe --- tests/phpunit/MediaWikiTestCase.php | 12 ++++++++++++ tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php | 5 ++--- tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php | 5 ++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index db75bc0b58..382bf500fe 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -2170,6 +2170,18 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { return $loaded; } + /** + * Skip the test if using the specified database type + * + * @param string $type Database type + * @since 1.32 + */ + protected function markTestSkippedIfDbType( $type ) { + if ( $this->db->getType() === $type ) { + $this->markTestSkipped( "The $type database type isn't supported for this test" ); + } + } + /** * Used as a marker to prevent wfResetOutputBuffers from breaking PHPUnit. * @param string $buffer diff --git a/tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php b/tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php index aebd0bf10e..3b270b31ad 100644 --- a/tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php +++ b/tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php @@ -13,9 +13,8 @@ class MediaWikiTestCaseSchema1Test extends MediaWikiTestCase { public function setUp() { parent::setUp(); - if ( $this->db->getType() == 'postgres' ) { - $this->markTestSkipped( __CLASS__ . ' does not support postgres' ); - } + // FIXME: fails under postgres + $this->markTestSkippedIfDbType( 'postgres' ); } public function getSchemaOverrides( IMaintainableDatabase $db ) { diff --git a/tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php b/tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php index c0673a10dc..391eec716a 100644 --- a/tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php +++ b/tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php @@ -16,9 +16,8 @@ class MediaWikiTestCaseSchema2Test extends MediaWikiTestCase { public function setUp() { parent::setUp(); - if ( $this->db->getType() == 'postgres' ) { - $this->markTestSkipped( __CLASS__ . ' does not support postgres' ); - } + // FIXME: fails under postgres + $this->markTestSkippedIfDbType( 'postgres' ); } public function testMediaWikiTestCaseSchemaTestOrder() { -- 2.20.1