[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Improve testing infrastructure

2016-12-05 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Improve testing infrastructure
..


Improve testing infrastructure

* Instead of a hacky 'sed -i' in composer.json, dynamically declare the class
  MediaWikiTestCase if missing (when PHPUnit is called directly).
* Check if phpdbg is installed, else use php
* Skip two tests when running HHVM because of issue #4797
  "Multiple calls of 'include' do not check for file modification HHVM 3.5.0"
  https://github.com/facebook/hhvm/issues/4797
  Possibly a workaround will be later added, but for now try to render
  MediaWikiFarm compatible with WMF CI suites
* Fixed two phpcs issues
* Dynamically create two JSON files with bad syntax (used in a test) to avoid
  trigerring a CI error report
* Made phpdoc optional for now

Bug: T151879
Change-Id: I17604c11e773f74f2c8b7ccb6aa7919cb729d552
---
M composer.json
M src/MediaWikiFarm.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/MediaWikiFarmTestCase.php
M tests/phpunit/MultiversionInstallationTest.php
D tests/phpunit/data/config/badsyntax.json
D tests/phpunit/data/config/empty.json
7 files changed, 35 insertions(+), 17 deletions(-)

Approvals:
  Seb35: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/composer.json b/composer.json
index 7a94498..61956c2 100644
--- a/composer.json
+++ b/composer.json
@@ -16,27 +16,21 @@
},
"require-dev": {
"justinrainbow/json-schema": "~3.0",
-   "phpdocumentor/phpdocumentor": "*",
"phpunit/phpunit": "~4.8",
"jakub-onderka/php-parallel-lint": "*",
"phpmd/phpmd": "*",
"mediawiki/mediawiki-codesniffer": "*"
},
+   "suggest": {
+   "phpdocumentor/phpdocumentor": "*"
+   },
"scripts": {
"validate-schema": "php ./bin/validate-schema.php",
"lint": "parallel-lint --exclude vendor .",
"phpcs": "phpcs -p -s",
-   "phpdoc": "phpdoc -d bin,src -t ./docs/code",
-   "phpunit": [
-   "sed -i 's/extends MediaWikiTestCase/extends 
PHPUnit_Framework_TestCase/' tests/phpunit/MediaWikiFarmTestCase.php",
-   "phpdbg -qrr `which phpunit` --strict-coverage",
-   "sed -i 's/extends PHPUnit_Framework_TestCase/extends 
MediaWikiTestCase/' tests/phpunit/MediaWikiFarmTestCase.php"
-   ],
-   "unit": [
-   "sed -i 's/extends MediaWikiTestCase/extends 
PHPUnit_Framework_TestCase/' tests/phpunit/MediaWikiFarmTestCase.php",
-   "phpunit --no-coverage",
-   "sed -i 's/extends PHPUnit_Framework_TestCase/extends 
MediaWikiTestCase/' tests/phpunit/MediaWikiFarmTestCase.php"
-   ],
+   "phpdoc": "[ \"`which phpdoc`\" = \"\" ] || phpdoc -d bin,src 
-t ./docs/code",
+   "phpunit": "which phpdbg && phpdbg -qrr `which phpunit` 
--strict-coverage || phpunit --strict-coverage",
+   "unit": "phpunit --no-coverage",
"test": [
"composer lint",
"composer unit",
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 7d47050..8a324ad 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -539,7 +539,9 @@
}
 
# Shortcut loading
+   // @codingStandardsIgnoreStart
if( $this->cacheDir && ( $result = $this->readFile( 
'versions.php', $this->cacheDir, false ) ) && array_key_exists( $host, $result 
) ) {
+   // @codingStandardsIgnoreEnd
$result = $result[$host];
$fresh = true;
$myfreshness = filemtime( $this->cacheDir . 
'/versions.php' );
diff --git a/tests/phpunit/ConfigurationTest.php 
b/tests/phpunit/ConfigurationTest.php
index 4c03391..7e4b13d 100644
--- a/tests/phpunit/ConfigurationTest.php
+++ b/tests/phpunit/ConfigurationTest.php
@@ -182,7 +182,6 @@
$farm->checkExistence();
$farm->getMediaWikiConfig();
$settings = $farm->getConfiguration( 'settings' );
-   #$this->assertEquals( [], $settings );
$extensions = $farm->getConfiguration( 'extensions' );
$skins = $farm->getConfiguration( 'skins' );
$this->assertTrue( 
$settings['wgUseExtensionTestExtensionBiLoading'] );
diff --git a/tests/phpunit/MediaWikiFarmTestCase.php 
b/tests/phpunit/MediaWikiFarmTestCase.php
index 9b5e037..d9493b6 100644
--- a/tests/phpunit/MediaWikiFarmTestCase.php
+++ b/tests/phpunit/MediaWikiFarmTestCase.php
@@ -9,6 +9,13 @@
 
 require_once dirname( dirname( dirname( __FILE__ ) ) ) . 
'/src/AbstractMediaWikiFarmScript.php';
 
+# These tests can be called either directly with PHPUnit or through the 
PHPUnit 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Improve testing

2016-12-01 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/324693

Change subject: Improve testing
..

Improve testing

* Instead of a hacky 'sed -i' in composer.json, dynamically declare the class
  MediaWikiTestCase if missing (when PHPUnit is called directly).
* Check if phpdbg is installed, else use php

Bug: T151879
Change-Id: I17604c11e773f74f2c8b7ccb6aa7919cb729d552
---
M composer.json
M tests/phpunit/MediaWikiFarmTestCase.php
2 files changed, 7 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm 
refs/changes/93/324693/1

diff --git a/composer.json b/composer.json
index 7a94498..ad08cc8 100644
--- a/composer.json
+++ b/composer.json
@@ -27,16 +27,8 @@
"lint": "parallel-lint --exclude vendor .",
"phpcs": "phpcs -p -s",
"phpdoc": "phpdoc -d bin,src -t ./docs/code",
-   "phpunit": [
-   "sed -i 's/extends MediaWikiTestCase/extends 
PHPUnit_Framework_TestCase/' tests/phpunit/MediaWikiFarmTestCase.php",
-   "phpdbg -qrr `which phpunit` --strict-coverage",
-   "sed -i 's/extends PHPUnit_Framework_TestCase/extends 
MediaWikiTestCase/' tests/phpunit/MediaWikiFarmTestCase.php"
-   ],
-   "unit": [
-   "sed -i 's/extends MediaWikiTestCase/extends 
PHPUnit_Framework_TestCase/' tests/phpunit/MediaWikiFarmTestCase.php",
-   "phpunit --no-coverage",
-   "sed -i 's/extends PHPUnit_Framework_TestCase/extends 
MediaWikiTestCase/' tests/phpunit/MediaWikiFarmTestCase.php"
-   ],
+   "phpunit": "which phpdbg && phpdbg -qrr `which phpunit` 
--strict-coverage || phpunit --strict-coverage",
+   "unit": "phpunit --no-coverage",
"test": [
"composer lint",
"composer unit",
diff --git a/tests/phpunit/MediaWikiFarmTestCase.php 
b/tests/phpunit/MediaWikiFarmTestCase.php
index 9b5e037..832dd72 100644
--- a/tests/phpunit/MediaWikiFarmTestCase.php
+++ b/tests/phpunit/MediaWikiFarmTestCase.php
@@ -9,6 +9,11 @@
 
 require_once dirname( dirname( dirname( __FILE__ ) ) ) . 
'/src/AbstractMediaWikiFarmScript.php';
 
+# When executing PHPUnit alone, this class does not exist
+if( !class_exists( 'MediaWikiTestCase' ) ) {
+
+   class MediaWikiTestCase extends PHPUnit_Framework_TestCase {}
+}
 
 abstract class MediaWikiFarmTestCase extends MediaWikiTestCase {
 

-- 
To view, visit https://gerrit.wikimedia.org/r/324693
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I17604c11e773f74f2c8b7ccb6aa7919cb729d552
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits