Hashar has uploaded a new change for review.
https://gerrit.wikimedia.org/r/63164
Change subject: PHPUnit now recognizes extension parser tests
......................................................................
PHPUnit now recognizes extension parser tests
*** *** *** *** WORK IN PROGRESS *** *** *** ***
The parser tests shipped by extension are not recognized by the
'extension' test suite. This change attempt to find them by looking at
the $wgParserFiles variable.
Play cases:
$ php phpunit.php --group Parser --tap
Only runs the MediaWiki core parser tests. FIXME: should run everything
With an extension having parser tests such as Cite:
$ php phpunit.php --testsuite extensions --tap
// Extensions tests are run including parser tests.
*** *** *** *** WORK IN PROGRESS *** *** *** ***
Got to figure out how to let all tests run which does not play nice with
PHPUnit right now :/
bug: 42506
Change-Id: Icc3e9d30706b32149aa9dd18552e4241ec4af67e
---
M tests/TestsAutoLoader.php
M tests/phpunit/includes/parser/MediaWikiParserTest.php
M tests/phpunit/suites/ExtensionsTestSuite.php
3 files changed, 75 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/64/63164/1
diff --git a/tests/TestsAutoLoader.php b/tests/TestsAutoLoader.php
index 4a6e3fb..8db3120 100644
--- a/tests/TestsAutoLoader.php
+++ b/tests/TestsAutoLoader.php
@@ -71,6 +71,7 @@
# tests/phpunit/includes/parser
'NewParserTest' => "$testDir/phpunit/includes/parser/NewParserTest.php",
+ 'MediaWikiParserTest' =>
"$testDir/phpunit/includes/parser/MediaWikiParserTest.php",
# tests/phpunit/includes/libs
'GenericArrayObjectTest' =>
"$testDir/phpunit/includes/libs/GenericArrayObjectTest.php",
diff --git a/tests/phpunit/includes/parser/MediaWikiParserTest.php
b/tests/phpunit/includes/parser/MediaWikiParserTest.php
index 3939c4f..12b4bec 100644
--- a/tests/phpunit/includes/parser/MediaWikiParserTest.php
+++ b/tests/phpunit/includes/parser/MediaWikiParserTest.php
@@ -11,12 +11,77 @@
*/
class MediaWikiParserTest {
- public static function suite() {
- global $wgParserTestFiles;
+ /**
+ * @defgroup filtering_constants Filtering constants
+ *
+ * Limit inclusion of parser tests files coming from MediaWiki core
+ * @{
+ */
+
+ /** Include files shipped with MediaWiki core */
+ const WITH_CORE = 1;
+ /** Include non core files as set in $wgParserTestFiles */
+ const WITH_REST = 2;
+ /** Include anything set via $wgParserTestFiles */
+ const WITH_ALL = 3; # WITH_CORE | WITH_REST
+
+ /** @} */
+
+ /**
+ * Get a PHPUnit test suite of parser tests. Optionally filtered with
+ * $flags.
+ *
+ * @par Examples:
+ * Get a suite of parser tests shipped by MediaWiki core:
+ * @code
+ * MediaWikiParserTest::suite( MediaWikiParserTest::WITH_CORE );
+ * @endcode
+ * Get a suite of various parser tests, like extensions:
+ * @code
+ * MediaWikiParserTest::suite( MediaWikiParserTest::WITH_REST );
+ * @endcode
+ * Get any test defined via $wgParserTestFiles:
+ * @code
+ * MediaWikiParserTest::suite( MediaWikiParserTest::WITH_ALL );
+ * @endcode
+ *
+ * @param $flags bitwise flag to filter out the $wgParserTestFiles that
+ * will be included. Default: MediaWikiParserTest::WITH_CORE
+ *
+ * @return PHPUnit_Framework_TestSuite
+ */
+ public static function suite( $flags = self::WITH_CORE ) {
+ var_dump("callled...");
+ if( is_string( $flags ) ) {
+ $flags = self::WITH_CORE;
+ }
+ global $wgParserTestFiles, $IP;
+
+ $mwTestDir = $IP.'/tests/';
+
+ $wantsCore = ($flags & self::WITH_CORE);
+ $wantsRest = ($flags & self::WITH_REST);
+ $filesToTest = array();
+ foreach( $wgParserTestFiles as $parserTestFile ) {
+ $isCore = ( 0 === strpos( $parserTestFile, $mwTestDir )
);
+
+ if( $isCore && $wantsCore ) {
+ var_dump( "IS CORE AND WE WANT CORE:
$parserTestFile\n" );
+ $filesToTest[] = $parserTestFile;
+ } elseif( !$isCore && $wantsRest ) {
+ var_dump( "IS NOT CORE BUT WANT REST:
$parserTestFile\n" );
+ $filesToTest[] = $parserTestFile;
+ } else {
+ var_dump( "ISCORE: $isCore WANTSCORE:
$wantsCore FLAGS: $flags");
+ }
+ }
$suite = new PHPUnit_Framework_TestSuite;
- foreach ( $wgParserTestFiles as $fileName ) {
+ var_dump( "TESTDIR: $mwTestDir" );
+ var_dump( "Globals: " .var_export( $wgParserTestFiles, 1 ) );
+ var_dump( "TO TEST: " .var_export( $filesToTest, 1 ) );
+ foreach ( $filesToTest as $fileName ) {
$testsName = basename( $fileName, '.txt' );
$escapedFileName = strtr( $fileName, array( "'" =>
"\\'", '\\' => '\\\\' ) );
/* This used to be ucfirst( basename( dirname(
$filename ) ) )
diff --git a/tests/phpunit/suites/ExtensionsTestSuite.php
b/tests/phpunit/suites/ExtensionsTestSuite.php
index eec773d..4692f93 100644
--- a/tests/phpunit/suites/ExtensionsTestSuite.php
+++ b/tests/phpunit/suites/ExtensionsTestSuite.php
@@ -15,6 +15,12 @@
if ( !count( $files ) ) {
$this->addTest( new DummyExtensionsTest( 'testNothing'
) );
}
+
+ $suites = MediaWikiParserTest::suite(
MediaWikiParserTest::WITH_REST );
+ foreach( $suites as $parserSuite ) {
+ $this->addTest( $parserSuite );
+ }
+
}
public static function suite() {
--
To view, visit https://gerrit.wikimedia.org/r/63164
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc3e9d30706b32149aa9dd18552e4241ec4af67e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Hashar <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits