Renames preparatory to parser tests refactor
Since in several cases, with an all-in-one commit, git's file rename detection failed, I split the renames out into their own commit to make review easier. Some changes here won't make complete sense without the following commit. * Moved TestsAutoLoader to tests/common/. It will be joined by a friend. * Renamed ParserTest to ParserTestRunner, since the former name was overly generic. * Renamed TestFileIterator to TestFileReader. Please see the subsequent commit for rationale. * Moved parserTests.php to tests/parser/. It was the only file left in tests/, and it should have been moved to tests/parser years ago, analogous to phpunit.php. * Renamed NewParserTest to ParserIntegrationTest. This was a tricky one, apparently the name has to end in "Test" or else the structure test will fail. Analogous to ParserMethodsTest etc. Rationale: because it's not new anymore. * Renamed MediaWikiParserTest to ParserTestTopLevelSuite and moved it to the suites directory. A more descriptive name. Being in suites/ shields it from StructureTests, and is correct anyway. Change-Id: Iddc6eaf815fdd64b3addb8570b4b6303ab99d634
This commit is contained in:
parent
fdd40afc42
commit
df29a359f8
15 changed files with 58 additions and 54 deletions
|
|
@ -1775,7 +1775,7 @@ class Parser {
|
|||
* Replace external links (REL)
|
||||
*
|
||||
* Note: this is all very hackish and the order of execution matters a lot.
|
||||
* Make sure to run tests/parserTests.php if you change this code.
|
||||
* Make sure to run tests/parser/parserTests.php if you change this code.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ help:
|
|||
@echo "Run 'make man' to run the doxygen generation with man pages."
|
||||
|
||||
test:
|
||||
php tests/parserTests.php --quiet
|
||||
php tests/parser/parserTests.php --quiet
|
||||
|
||||
doc:
|
||||
php mwdocgen.php --all
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class CheckLess extends Maintenance {
|
|||
// NOTE (phuedx, 2014-03-26) wgAutoloadClasses isn't set up
|
||||
// by either of the dependencies at the top of the file, so
|
||||
// require it here.
|
||||
require_once __DIR__ . '/../tests/TestsAutoLoader.php';
|
||||
require_once __DIR__ . '/../tests/common/TestsAutoLoader.php';
|
||||
|
||||
// If phpunit isn't available by autoloader try pulling it in
|
||||
if ( !class_exists( 'PHPUnit_Framework_TestCase' ) ) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
|
||||
global $wgAutoloadClasses;
|
||||
$testDir = __DIR__;
|
||||
$testDir = __DIR__ . '/..';
|
||||
|
||||
$wgAutoloadClasses += [
|
||||
|
||||
|
|
@ -135,14 +135,13 @@ $wgAutoloadClasses += [
|
|||
'DelayedParserTest' => "$testDir/parser/DelayedParserTest.php",
|
||||
'DjVuSupport' => "$testDir/parser/DjVuSupport.php",
|
||||
'ITestRecorder' => "$testDir/parser/ITestRecorder.php",
|
||||
'MediaWikiParserTest' => "$testDir/phpunit/includes/parser/MediaWikiParserTest.php",
|
||||
'NewParserTest' => "$testDir/phpunit/includes/parser/NewParserTest.php",
|
||||
'ParserTest' => "$testDir/parser/ParserTest.php",
|
||||
'ParserIntegrationTest' => "$testDir/phpunit/includes/parser/ParserIntegrationTest.php",
|
||||
'ParserTestRunner' => "$testDir/parser/ParserTestRunner.php",
|
||||
'ParserTestParserHook' => "$testDir/parser/ParserTestParserHook.php",
|
||||
'ParserTestResult' => "$testDir/parser/ParserTestResult.php",
|
||||
'ParserTestResultNormalizer' => "$testDir/parser/ParserTestResultNormalizer.php",
|
||||
'TestFileDataProvider' => "$testDir/parser/TestFileDataProvider.php",
|
||||
'TestFileIterator' => "$testDir/parser/TestFileIterator.php",
|
||||
'TestFileReader' => "$testDir/parser/TestFileReader.php",
|
||||
'TestRecorder' => "$testDir/parser/TestRecorder.php",
|
||||
'TidySupport' => "$testDir/parser/TidySupport.php",
|
||||
|
||||
|
|
@ -152,4 +151,7 @@ $wgAutoloadClasses += [
|
|||
|
||||
# tests/phpunit/includes/specialpage
|
||||
'SpecialPageTestHelper' => "$testDir/phpunit/includes/specialpage/SpecialPageTestHelper.php",
|
||||
|
||||
# tests/phpunit/suites
|
||||
'ParserTestTopLevelSuite' => "$testDir/phpunit/suites/ParserTestTopLevelSuite.php",
|
||||
];
|
||||
|
|
@ -47,14 +47,16 @@ class DelayedParserTest {
|
|||
/**
|
||||
* Called whenever we actually want to run the hook.
|
||||
* Should be the case if we found the parserTest is not disabled
|
||||
* @param ParserTest|NewParserTest $parserTest
|
||||
* @param ParserTestRunner|ParserIntegrationTest $parserTest
|
||||
* @return bool
|
||||
* @throws MWException
|
||||
*/
|
||||
public function unleash( &$parserTest ) {
|
||||
if ( !( $parserTest instanceof ParserTest || $parserTest instanceof NewParserTest ) ) {
|
||||
throw new MWException( __METHOD__ . " must be passed an instance of ParserTest or "
|
||||
. "NewParserTest classes\n" );
|
||||
if ( !( $parserTest instanceof ParserTestRunner
|
||||
|| $parserTest instanceof ParserIntegrationTest )
|
||||
) {
|
||||
throw new MWException( __METHOD__ . " must be passed an instance of " .
|
||||
"ParserTestRunner or ParserIntegrationTest classes\n" );
|
||||
}
|
||||
|
||||
# Trigger delayed hooks. Any failure will make us abort
|
||||
|
|
@ -86,7 +88,7 @@ class DelayedParserTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Similar to ParserTest object but does not run anything
|
||||
* Similar to ParserTestRunner object but does not run anything
|
||||
* Use unleash() to really execute the hook
|
||||
* @param string $hook
|
||||
*/
|
||||
|
|
@ -95,7 +97,7 @@ class DelayedParserTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Similar to ParserTest object but does not run anything
|
||||
* Similar to ParserTestRunner object but does not run anything
|
||||
* Use unleash() to really execute the hook function
|
||||
* @param string $fnHook
|
||||
*/
|
||||
|
|
@ -104,7 +106,7 @@ class DelayedParserTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Similar to ParserTest object but does not run anything
|
||||
* Similar to ParserTestRunner object but does not run anything
|
||||
* Use unleash() to really execute the hook function
|
||||
* @param string $hook
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Helper code for the MediaWiki parser test suite. Some code is duplicated
|
||||
* in PHPUnit's NewParserTests.php, so you'll probably want to update both
|
||||
* in PHPUnit's ParserIntegrationTest.php, so you'll probably want to update both
|
||||
* at the same time.
|
||||
*
|
||||
* Copyright © 2004, 2010 Brion Vibber <brion@pobox.com>
|
||||
|
|
@ -32,7 +32,7 @@ use MediaWiki\MediaWikiServices;
|
|||
/**
|
||||
* @ingroup Testing
|
||||
*/
|
||||
class ParserTest {
|
||||
class ParserTestRunner {
|
||||
/**
|
||||
* @var bool $color whereas output should be colorized
|
||||
*/
|
||||
|
|
@ -395,7 +395,7 @@ class ParserTest {
|
|||
public function runTestsFromFiles( $filenames ) {
|
||||
$ok = false;
|
||||
|
||||
// be sure, ParserTest::addArticle has correct language set,
|
||||
// be sure, ParserTestRunner::addArticle has correct language set,
|
||||
// so that system messages gets into the right language cache
|
||||
$GLOBALS['wgLanguageCode'] = 'en';
|
||||
$GLOBALS['wgContLang'] = Language::factory( 'en' );
|
||||
|
|
@ -407,7 +407,7 @@ class ParserTest {
|
|||
|
||||
foreach ( $filenames as $filename ) {
|
||||
echo "Running parser tests from: $filename\n";
|
||||
$tests = new TestFileIterator( $filename, $this );
|
||||
$tests = new TestFileReader( $filename, $this );
|
||||
$ok = $this->runTests( $tests ) && $ok;
|
||||
}
|
||||
|
||||
|
|
@ -838,7 +838,7 @@ class ParserTest {
|
|||
global $wgHooks;
|
||||
|
||||
$wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup';
|
||||
$wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
|
||||
$wgHooks['ParserGetVariableValueTs'][] = 'ParserTestRunner::getFakeTimestamp';
|
||||
|
||||
MagicWord::clearCache();
|
||||
MWTidy::destroySingleton();
|
||||
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
/**
|
||||
* An iterator for use as a phpunit data provider. Provides the test arguments
|
||||
* in the order expected by NewParserTest::testParserTest().
|
||||
* in the order expected by ParserIntegrationTest::testParserTest().
|
||||
*/
|
||||
class TestFileDataProvider extends TestFileIterator {
|
||||
class TestFileDataProvider extends TestFileReader {
|
||||
function current() {
|
||||
$test = parent::current();
|
||||
if ( $test ) {
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@
|
|||
* @ingroup Testing
|
||||
*/
|
||||
|
||||
class TestFileIterator implements Iterator {
|
||||
class TestFileReader implements Iterator {
|
||||
private $file;
|
||||
private $fh;
|
||||
/**
|
||||
* @var ParserTest|MediaWikiParserTest An instance of ParserTest (parserTests.php)
|
||||
* or MediaWikiParserTest (phpunit)
|
||||
* @var ParserTestRunner|ParserTestTopLevelSuite An instance of ParserTestRunner
|
||||
* (parserTests.php) or ParserTestTopLevelSuite (phpunit)
|
||||
*/
|
||||
private $parserTest;
|
||||
private $index = 0;
|
||||
|
|
@ -134,12 +134,12 @@ class TestFileIterator implements Iterator {
|
|||
}
|
||||
|
||||
$this->test = [
|
||||
'test' => ParserTest::chomp( $this->sectionData['test'] ),
|
||||
'test' => ParserTestRunner::chomp( $this->sectionData['test'] ),
|
||||
'subtest' => $this->nextSubTest,
|
||||
'input' => ParserTest::chomp( $this->sectionData[$input] ),
|
||||
'result' => ParserTest::chomp( $this->sectionData[$result] ),
|
||||
'options' => ParserTest::chomp( $this->sectionData['options'] ),
|
||||
'config' => ParserTest::chomp( $this->sectionData['config'] ),
|
||||
'input' => ParserTestRunner::chomp( $this->sectionData[$input] ),
|
||||
'result' => ParserTestRunner::chomp( $this->sectionData[$result] ),
|
||||
'options' => ParserTestRunner::chomp( $this->sectionData['options'] ),
|
||||
'config' => ParserTestRunner::chomp( $this->sectionData['config'] ),
|
||||
];
|
||||
if ( $tidy != false ) {
|
||||
$this->test['options'] .= " tidy";
|
||||
|
|
@ -171,7 +171,7 @@ class TestFileIterator implements Iterator {
|
|||
$this->checkSection( 'article' );
|
||||
|
||||
$this->parserTest->addArticle(
|
||||
ParserTest::chomp( $this->sectionData['article'] ),
|
||||
ParserTestRunner::chomp( $this->sectionData['article'] ),
|
||||
$this->sectionData['text'], $this->lineNum );
|
||||
|
||||
$this->clearSection();
|
||||
|
|
@ -22,13 +22,13 @@ class ParserFuzzTest extends Maintenance {
|
|||
}
|
||||
|
||||
function finalSetup() {
|
||||
require_once __DIR__ . '/../TestsAutoLoader.php';
|
||||
require_once __DIR__ . '/../common/TestsAutoLoader.php';
|
||||
}
|
||||
|
||||
function execute() {
|
||||
$files = $this->getOption( 'file', [ __DIR__ . '/parserTests.txt' ] );
|
||||
$this->seed = intval( $this->getOption( 'seed', 1 ) ) - 1;
|
||||
$this->parserTest = new ParserTest;
|
||||
$this->parserTest = new ParserTestRunner;
|
||||
$this->fuzzTest( $files );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ $options = [ 'quick', 'color', 'quiet', 'help', 'show-output',
|
|||
'record', 'run-disabled', 'run-parsoid', 'dwdiff', 'mark-ws' ];
|
||||
$optionsWithArgs = [ 'regex', 'filter', 'seed', 'setversion', 'file', 'norm' ];
|
||||
|
||||
require_once __DIR__ . '/../maintenance/commandLine.inc';
|
||||
require_once __DIR__ . '/TestsAutoLoader.php';
|
||||
require_once __DIR__ . '/../../maintenance/commandLine.inc';
|
||||
require_once __DIR__ . '/../common/TestsAutoLoader.php';
|
||||
|
||||
if ( isset( $options['help'] ) ) {
|
||||
echo <<<ENDS
|
||||
|
|
@ -79,7 +79,7 @@ if ( $wgDBtype == 'sqlite' ) {
|
|||
}
|
||||
}
|
||||
|
||||
$tester = new ParserTest( $options );
|
||||
$tester = new ParserTestRunner( $options );
|
||||
|
||||
if ( isset( $options['file'] ) ) {
|
||||
$files = [ $options['file'] ];
|
||||
|
|
@ -11,7 +11,7 @@ use MediaWiki\MediaWikiServices;
|
|||
*
|
||||
* @todo covers tags
|
||||
*/
|
||||
class NewParserTest extends MediaWikiTestCase {
|
||||
class ParserIntegrationTest extends MediaWikiTestCase {
|
||||
static protected $articles = []; // Array of test articles defined by the tests
|
||||
/* The data provider is run on a different instance than the test, so it must be static
|
||||
* When running tests from several files, all tests will see all articles.
|
||||
|
|
@ -41,8 +41,8 @@ class NewParserTest extends MediaWikiTestCase {
|
|||
protected $file = false;
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
// Inject ParserTest well-known interwikis
|
||||
ParserTest::setupInterwikis();
|
||||
// Inject ParserTestRunner well-known interwikis
|
||||
ParserTestRunner::setupInterwikis();
|
||||
}
|
||||
|
||||
protected function setUp() {
|
||||
|
|
@ -127,7 +127,7 @@ class NewParserTest extends MediaWikiTestCase {
|
|||
|
||||
$tmpHooks = $wgHooks;
|
||||
$tmpHooks['ParserTestParser'][] = 'ParserTestParserHook::setup';
|
||||
$tmpHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
|
||||
$tmpHooks['ParserGetVariableValueTs'][] = 'ParserTestRunner::getFakeTimestamp';
|
||||
$tmpGlobals['wgHooks'] = $tmpHooks;
|
||||
# add a namespace shadowing a interwiki link, to test
|
||||
# proper precedence when resolving links. (bug 51680)
|
||||
|
|
@ -158,7 +158,7 @@ class NewParserTest extends MediaWikiTestCase {
|
|||
|
||||
MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
|
||||
$wgContLang->resetNamespaces(); # reset namespace cache
|
||||
ParserTest::resetTitleServices();
|
||||
ParserTestRunner::resetTitleServices();
|
||||
MediaWikiServices::getInstance()->disableService( 'MediaHandlerFactory' );
|
||||
MediaWikiServices::getInstance()->redefineService(
|
||||
'MediaHandlerFactory',
|
||||
|
|
@ -194,7 +194,7 @@ class NewParserTest extends MediaWikiTestCase {
|
|||
}
|
||||
|
||||
public static function tearDownAfterClass() {
|
||||
ParserTest::tearDownInterwikis();
|
||||
ParserTestRunner::tearDownInterwikis();
|
||||
parent::tearDownAfterClass();
|
||||
}
|
||||
|
||||
|
|
@ -367,7 +367,7 @@ class NewParserTest extends MediaWikiTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
// ParserTest setup/teardown functions
|
||||
// ParserTestRunner setup/teardown functions
|
||||
|
||||
/**
|
||||
* Set up the global variables for a consistent environment for each test.
|
||||
|
|
@ -861,7 +861,7 @@ class NewParserTest extends MediaWikiTestCase {
|
|||
|
||||
foreach ( self::$articles as $name => $info ) {
|
||||
list( $text, $line ) = $info;
|
||||
ParserTest::addArticle( $name, $text, $line, 'ignoreduplicate' );
|
||||
ParserTestRunner::addArticle( $name, $text, $line, 'ignoreduplicate' );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ class PHPUnitMaintClass extends Maintenance {
|
|||
global $wgAuthManagerConfig, $wgAuth;
|
||||
|
||||
// Inject test autoloader
|
||||
require_once __DIR__ . '/../TestsAutoLoader.php';
|
||||
require_once __DIR__ . '/../common/TestsAutoLoader.php';
|
||||
|
||||
// wfWarn should cause tests to fail
|
||||
$wgDevelopmentWarnings = true;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<directory>languages</directory>
|
||||
</testsuite>
|
||||
<testsuite name="parsertests">
|
||||
<file>includes/parser/MediaWikiParserTest.php</file>
|
||||
<file>suites/ParserTestTopLevelSuite.php</file>
|
||||
<file>suites/ExtensionsParserTestSuite.php</file>
|
||||
</testsuite>
|
||||
<testsuite name="skins">
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
class ExtensionsParserTestSuite extends PHPUnit_Framework_TestSuite {
|
||||
|
||||
public static function suite() {
|
||||
return MediaWikiParserTest::suite( MediaWikiParserTest::NO_CORE );
|
||||
return ParserTestTopLevelSuite::suite( ParserTestTopLevelSuite::NO_CORE );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/NewParserTest.php';
|
||||
require_once __DIR__ . '/../includes/parser/ParserIntegrationTest.php';
|
||||
|
||||
/**
|
||||
* The UnitTest must be either a class that inherits from MediaWikiTestCase
|
||||
|
|
@ -10,7 +10,7 @@ require_once __DIR__ . '/NewParserTest.php';
|
|||
* @group ParserTests
|
||||
* @group Database
|
||||
*/
|
||||
class MediaWikiParserTest {
|
||||
class ParserTestTopLevelSuite {
|
||||
|
||||
/**
|
||||
* @defgroup filtering_constants Filtering constants
|
||||
|
|
@ -35,19 +35,19 @@ class MediaWikiParserTest {
|
|||
* @par Examples:
|
||||
* Get a suite of parser tests shipped by MediaWiki core:
|
||||
* @code
|
||||
* MediaWikiParserTest::suite( MediaWikiParserTest::CORE_ONLY );
|
||||
* ParserTestTopLevelSuite::suite( ParserTestTopLevelSuite::CORE_ONLY );
|
||||
* @endcode
|
||||
* Get a suite of various parser tests, like extensions:
|
||||
* @code
|
||||
* MediaWikiParserTest::suite( MediaWikiParserTest::NO_CORE );
|
||||
* ParserTestTopLevelSuite::suite( ParserTestTopLevelSuite::NO_CORE );
|
||||
* @endcode
|
||||
* Get any test defined via $wgParserTestFiles:
|
||||
* @code
|
||||
* MediaWikiParserTest::suite( MediaWikiParserTest::WITH_ALL );
|
||||
* ParserTestTopLevelSuite::suite( ParserTestTopLevelSuite::WITH_ALL );
|
||||
* @endcode
|
||||
*
|
||||
* @param int $flags Bitwise flag to filter out the $wgParserTestFiles that
|
||||
* will be included. Default: MediaWikiParserTest::CORE_ONLY
|
||||
* will be included. Default: ParserTestTopLevelSuite::CORE_ONLY
|
||||
*
|
||||
* @return PHPUnit_Framework_TestSuite
|
||||
*/
|
||||
|
|
@ -116,7 +116,7 @@ class MediaWikiParserTest {
|
|||
* @group ParserTests
|
||||
* @group ParserTests_$parserTestClassName
|
||||
*/
|
||||
class $parserTestClassName extends NewParserTest {
|
||||
class $parserTestClassName extends ParserIntegrationTest {
|
||||
protected \$file = '$escapedFileName';
|
||||
}
|
||||
EOT;
|
||||
Loading…
Reference in a new issue