2012-01-09 22:33:00 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* Generic backend for the MediaWiki parser test suite, used by both the
|
|
|
|
|
* standalone parserTests.php and the PHPUnit "parsertests" suite.
|
2012-10-02 20:24:33 +00:00
|
|
|
*
|
|
|
|
|
* Copyright © 2004, 2010 Brion Vibber <brion@pobox.com>
|
2014-03-20 15:45:01 +00:00
|
|
|
* https://www.mediawiki.org/
|
2012-10-02 20:24:33 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2012-01-09 22:33:00 +00:00
|
|
|
* @todo Make this more independent of the configuration (and if possible the database)
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup Testing
|
|
|
|
|
*/
|
2019-07-04 10:01:31 +00:00
|
|
|
|
2020-12-18 22:32:27 +00:00
|
|
|
use MediaWiki\Interwiki\ClassicInterwikiLookup;
|
2022-04-27 15:42:24 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
2016-04-25 05:41:32 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2022-07-26 18:16:28 +00:00
|
|
|
use MediaWiki\Parser\ParserOutputFlags;
|
2020-06-10 08:40:05 +00:00
|
|
|
use MediaWiki\Revision\MutableRevisionRecord;
|
2020-07-03 00:20:38 +00:00
|
|
|
use MediaWiki\Revision\RevisionRecord;
|
2020-06-10 08:40:05 +00:00
|
|
|
use MediaWiki\Revision\SlotRecord;
|
2022-10-25 16:58:49 +00:00
|
|
|
use MediaWiki\StubObject\StubGlobalUser;
|
2021-03-31 16:50:45 +00:00
|
|
|
use Psr\Log\NullLogger;
|
2022-05-20 20:42:25 +00:00
|
|
|
use Wikimedia\Assert\Assert;
|
2022-03-14 18:36:57 +00:00
|
|
|
use Wikimedia\Parsoid\Config\PageConfig;
|
2022-05-20 20:42:25 +00:00
|
|
|
use Wikimedia\Parsoid\Config\SiteConfig;
|
2022-04-04 10:44:11 +00:00
|
|
|
use Wikimedia\Parsoid\Core\SelserData;
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
use Wikimedia\Parsoid\DOM\Document;
|
2022-05-20 20:42:25 +00:00
|
|
|
use Wikimedia\Parsoid\Ext\ExtensionModule;
|
|
|
|
|
use Wikimedia\Parsoid\ParserTests\Article as ParserTestArticle;
|
2020-07-24 04:41:09 +00:00
|
|
|
use Wikimedia\Parsoid\ParserTests\ParserHook as ParsoidParserHook;
|
|
|
|
|
use Wikimedia\Parsoid\ParserTests\RawHTML as ParsoidRawHTML;
|
|
|
|
|
use Wikimedia\Parsoid\ParserTests\StyleTag as ParsoidStyleTag;
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
use Wikimedia\Parsoid\ParserTests\Test as ParserTest;
|
2022-05-20 20:42:25 +00:00
|
|
|
use Wikimedia\Parsoid\ParserTests\TestFileReader;
|
2022-08-16 20:25:05 +00:00
|
|
|
use Wikimedia\Parsoid\ParserTests\TestMode as ParserTestMode;
|
2020-07-24 04:41:09 +00:00
|
|
|
use Wikimedia\Parsoid\Parsoid;
|
2022-04-04 10:44:11 +00:00
|
|
|
use Wikimedia\Parsoid\Utils\ContentUtils;
|
|
|
|
|
use Wikimedia\Parsoid\Utils\DOMCompat;
|
2022-05-20 20:42:25 +00:00
|
|
|
use Wikimedia\Parsoid\Utils\DOMDataUtils;
|
2022-03-15 11:15:18 +00:00
|
|
|
use Wikimedia\Parsoid\Utils\DOMUtils;
|
2022-05-27 20:38:32 +00:00
|
|
|
use Wikimedia\Rdbms\DBError;
|
|
|
|
|
use Wikimedia\Rdbms\IDatabase;
|
2016-10-12 05:36:03 +00:00
|
|
|
use Wikimedia\ScopedCallback;
|
2017-06-27 21:09:12 +00:00
|
|
|
use Wikimedia\TestingAccessWrapper;
|
2012-01-09 22:33:00 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ingroup Testing
|
|
|
|
|
*/
|
2016-09-08 01:07:06 +00:00
|
|
|
class ParserTestRunner {
|
2017-07-07 22:26:21 +00:00
|
|
|
|
2012-01-09 22:33:00 +00:00
|
|
|
/**
|
2020-10-28 19:44:09 +00:00
|
|
|
* @var array The status of each setup function
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
private $setupDone = [
|
|
|
|
|
'staticSetup' => false,
|
|
|
|
|
'perTestSetup' => false,
|
|
|
|
|
'setupDatabase' => false,
|
|
|
|
|
'setupUploads' => false,
|
|
|
|
|
];
|
2012-01-09 22:33:00 +00:00
|
|
|
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
/**
|
|
|
|
|
* @var array (CLI/Config) Options for the test runner
|
|
|
|
|
* See the constructor for documentation
|
|
|
|
|
*/
|
|
|
|
|
private $options;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var array set of requested test modes
|
|
|
|
|
*/
|
|
|
|
|
private $requestedTestModes;
|
|
|
|
|
|
2012-01-09 22:33:00 +00:00
|
|
|
/**
|
|
|
|
|
* Our connection to the database
|
2022-05-27 20:38:32 +00:00
|
|
|
* @var IDatabase
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
|
|
|
|
private $db;
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
/**
|
|
|
|
|
* @var TestRecorder
|
2016-07-26 09:39:15 +00:00
|
|
|
*/
|
|
|
|
|
private $recorder;
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
/**
|
|
|
|
|
* The upload directory, or null to not set up an upload directory
|
|
|
|
|
*
|
|
|
|
|
* @var string|null
|
|
|
|
|
*/
|
2012-01-09 22:33:00 +00:00
|
|
|
private $uploadDir = null;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-03-08 11:40:54 +00:00
|
|
|
* The name of the file backend to use, or false to use MockFileBackend.
|
|
|
|
|
* @var string|false
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
private $fileBackendName;
|
2012-01-09 22:33:00 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
/**
|
|
|
|
|
* A complete regex for filtering tests.
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
private $regex;
|
2012-01-09 22:33:00 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
/**
|
|
|
|
|
* A list of normalization functions to apply to the expected and actual
|
|
|
|
|
* output.
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
private $normalizationFunctions = [];
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2018-07-20 02:03:48 +00:00
|
|
|
/**
|
|
|
|
|
* Run disabled parser tests
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
|
|
|
|
private $runDisabled;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Disable parse on article insertion
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
|
|
|
|
private $disableSaveParse;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reuse upload directory
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
|
|
|
|
private $keepUploads;
|
|
|
|
|
|
2019-07-04 10:01:31 +00:00
|
|
|
/** @var Title */
|
|
|
|
|
private $defaultTitle;
|
|
|
|
|
|
2022-07-27 18:18:17 +00:00
|
|
|
/**
|
|
|
|
|
* Did some Parsoid test pass where it was expected to fail?
|
|
|
|
|
* This can happen if the test failure is recorded in the -knownFailures.json file
|
|
|
|
|
* but the test result changed, or functionality changed that causes tests to pass.
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
|
|
|
|
public $unexpectedTestPasses = false;
|
|
|
|
|
|
2020-12-23 18:52:12 +00:00
|
|
|
/**
|
|
|
|
|
* Table name prefix.
|
|
|
|
|
*/
|
|
|
|
|
public const DB_PREFIX = 'parsertest_';
|
|
|
|
|
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
/**
|
|
|
|
|
* Compute the set of valid test runner modes
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getRequestedTestModes(): array {
|
|
|
|
|
return $this->requestedTestModes;
|
|
|
|
|
}
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
/**
|
|
|
|
|
* @param TestRecorder $recorder
|
|
|
|
|
* @param array $options
|
2022-05-14 05:06:03 +00:00
|
|
|
* - parsoid (bool) if true, run Parsoid tests
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
* - testFile (string)
|
|
|
|
|
* If set, the (Parsoid) test file to run tests from.
|
|
|
|
|
* Currently, only used for CLI PHPUnit test runs
|
|
|
|
|
* to avoid running every single test file out there.
|
|
|
|
|
* Legacy parser test runs ignore this option.
|
|
|
|
|
* - wt2html (bool) If true, run Parsoid wt2html tests
|
|
|
|
|
* - wt2wt (bool) If true, run Parsoid wt2wt tests
|
|
|
|
|
* - html2wt (bool) If true, run Parsoid html2wt tests
|
|
|
|
|
* - html2html (bool) If true, run Parsoid html2html tests
|
|
|
|
|
* - selser (bool/"noauto")
|
|
|
|
|
* If true, run Parsoid auto-generated selser tests
|
|
|
|
|
* If "noauto", run Parsoid manual edit selser tests
|
2022-05-14 05:06:03 +00:00
|
|
|
* - numchanges (int) number of selser edit tests to generate
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
* - changetree (array|null)
|
|
|
|
|
* If not null, run a Parsoid selser edit test with this changetree
|
|
|
|
|
* - updateKnownFailures (bool)
|
|
|
|
|
* If true, *knownFailures.json files are updated
|
|
|
|
|
* - norm (array)
|
|
|
|
|
* An array of normalization functions to run on test output
|
|
|
|
|
* to use in legacy parser test runs
|
|
|
|
|
* - regex (string) Regex for filtering tests
|
|
|
|
|
* - run-disabled (bool) If true, run disabled tests
|
|
|
|
|
* - keep-uploads (bool) If true, reuse upload directory
|
|
|
|
|
* - file-backend (string|bool)
|
|
|
|
|
* If false, use MockFileBackend
|
|
|
|
|
* Else name of the file backend to use
|
|
|
|
|
* - disable-save-parse (bool) if true, disable parse on article insertion
|
|
|
|
|
*
|
|
|
|
|
* NOTE: At this time, Parsoid-specific test options are only handled
|
|
|
|
|
* in PHPUnit mode. A future patch will likely tweak some of this and
|
|
|
|
|
* support these flags no matter how this test runner is instantiated.
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
*/
|
|
|
|
|
public function __construct( TestRecorder $recorder, $options = [] ) {
|
|
|
|
|
$this->recorder = $recorder;
|
2022-05-20 21:36:02 +00:00
|
|
|
$this->options = $options + [
|
|
|
|
|
'keep-uploads' => false,
|
|
|
|
|
'file-backend' => false,
|
|
|
|
|
'run-disabled' => false,
|
|
|
|
|
'disable-save-parse' => false,
|
|
|
|
|
'upload-dir' => null,
|
|
|
|
|
'regex' => false,
|
|
|
|
|
'norm' => [],
|
|
|
|
|
// Parsoid-specific options
|
|
|
|
|
'parsoid' => false,
|
|
|
|
|
'knownFailures' => true,
|
|
|
|
|
'updateKnownFailures' => false,
|
|
|
|
|
'changetree' => null,
|
2022-05-20 20:42:25 +00:00
|
|
|
// Options can also match those in ParserTestModes::TEST_MODES
|
|
|
|
|
// but we don't need to initialize those here; they will be
|
|
|
|
|
// accessed via $this->requestedTestModes instead.
|
2022-05-20 21:36:02 +00:00
|
|
|
];
|
|
|
|
|
// Requested test modes are used for Parsoid tests and ignored for
|
|
|
|
|
// legacy parser tests.
|
2022-05-20 20:42:25 +00:00
|
|
|
$this->requestedTestModes = ParserTestMode::requestedTestModes(
|
|
|
|
|
$this->options
|
|
|
|
|
);
|
2022-05-20 21:36:02 +00:00
|
|
|
|
2022-06-01 21:19:57 +00:00
|
|
|
// @phan-suppress-next-line PhanEmptyForeach False positive
|
2022-05-20 21:36:02 +00:00
|
|
|
foreach ( $this->options['norm'] as $func ) {
|
|
|
|
|
if ( in_array( $func, [ 'removeTbody', 'trimWhitespace' ] ) ) {
|
|
|
|
|
$this->normalizationFunctions[] = $func;
|
|
|
|
|
} else {
|
|
|
|
|
$this->recorder->warning(
|
|
|
|
|
"Warning: unknown normalization option \"$func\"\n" );
|
2016-03-09 04:42:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2022-05-20 21:36:02 +00:00
|
|
|
if ( $this->options['regex'] !== false ) {
|
|
|
|
|
$this->regex = $this->options['regex'];
|
2012-01-09 22:33:00 +00:00
|
|
|
} else {
|
|
|
|
|
# Matches anything
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$this->regex = '//';
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-20 21:36:02 +00:00
|
|
|
$this->keepUploads = (bool)$this->options['keep-uploads'];
|
|
|
|
|
$this->fileBackendName = $this->options['file-backend'];
|
|
|
|
|
$this->runDisabled = (bool)$this->options['run-disabled'];
|
|
|
|
|
$this->disableSaveParse = (bool)$this->options['disable-save-parse'];
|
|
|
|
|
$this->uploadDir = $this->options['upload-dir'];
|
2019-07-04 10:01:31 +00:00
|
|
|
|
|
|
|
|
$this->defaultTitle = Title::newFromText( 'Parser test' );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
/**
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getOptions(): array {
|
|
|
|
|
return $this->options;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-07 22:26:21 +00:00
|
|
|
/**
|
|
|
|
|
* Get list of filenames to extension and core parser tests
|
|
|
|
|
*
|
2022-10-24 18:05:51 +00:00
|
|
|
* @param array $dirs
|
2017-07-07 22:26:21 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
2022-10-24 18:05:51 +00:00
|
|
|
public static function getParserTestFiles( array $dirs = [] ): array {
|
|
|
|
|
if ( $dirs ) {
|
|
|
|
|
$ptDirs = [];
|
|
|
|
|
foreach ( $dirs as $i => $dir ) {
|
|
|
|
|
if ( !is_dir( $dir ) ) {
|
|
|
|
|
echo "$dir is not a directory. Skipping it.\n";
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$ptDirs["_CLI{$i}_"] = $dir;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// Auto-discover core test files
|
|
|
|
|
$ptDirs = [ 'core' => __DIR__ ];
|
2017-07-07 22:26:21 +00:00
|
|
|
|
2022-10-24 18:05:51 +00:00
|
|
|
// Auto-discover extension parser tests
|
|
|
|
|
$registry = ExtensionRegistry::getInstance();
|
|
|
|
|
foreach ( $registry->getAllThings() as $info ) {
|
|
|
|
|
$dir = dirname( $info['path'] ) . '/tests/parser';
|
|
|
|
|
if ( !is_dir( $dir ) ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$ptDirs[ $info['name'] ] = $dir;
|
2017-07-07 22:26:21 +00:00
|
|
|
}
|
2022-10-12 21:09:59 +00:00
|
|
|
}
|
2022-10-24 18:05:51 +00:00
|
|
|
|
2022-10-12 21:09:59 +00:00
|
|
|
$files = [];
|
|
|
|
|
foreach ( $ptDirs as $extName => $dir ) {
|
2017-07-08 07:14:13 +00:00
|
|
|
$counter = 1;
|
2017-07-07 22:26:21 +00:00
|
|
|
$dirIterator = new RecursiveIteratorIterator(
|
|
|
|
|
new RecursiveDirectoryIterator( $dir )
|
|
|
|
|
);
|
|
|
|
|
foreach ( $dirIterator as $fileInfo ) {
|
|
|
|
|
/** @var SplFileInfo $fileInfo */
|
2022-04-13 13:44:41 +00:00
|
|
|
if ( str_ends_with( $fileInfo->getFilename(), '.txt' ) ) {
|
2022-10-12 21:09:59 +00:00
|
|
|
$name = $extName . '_' . $counter;
|
2017-07-08 07:14:13 +00:00
|
|
|
while ( isset( $files[$name] ) ) {
|
2020-07-24 04:07:56 +00:00
|
|
|
$counter++;
|
2022-10-12 21:09:59 +00:00
|
|
|
$name = $extName . '_' . $counter;
|
2017-07-08 07:14:13 +00:00
|
|
|
}
|
|
|
|
|
$files[$name] = $fileInfo->getPathname();
|
2017-07-07 22:26:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return array_unique( $files );
|
|
|
|
|
}
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
public function getRecorder() {
|
|
|
|
|
return $this->recorder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Do any setup which can be done once for all tests, independent of test
|
|
|
|
|
* options, except for database setup.
|
|
|
|
|
*
|
|
|
|
|
* Public setup functions in this class return a ScopedCallback object. When
|
|
|
|
|
* this object is destroyed by going out of scope, teardown of the
|
|
|
|
|
* corresponding test setup is performed.
|
|
|
|
|
*
|
|
|
|
|
* Teardown objects may be chained by passing a ScopedCallback from a
|
|
|
|
|
* previous setup stage as the $nextTeardown parameter. This enforces the
|
|
|
|
|
* convention that teardown actions are taken in reverse order to the
|
|
|
|
|
* corresponding setup actions. When $nextTeardown is specified, a
|
|
|
|
|
* ScopedCallback will be returned which first tears down the current
|
|
|
|
|
* setup stage, and then tears down the previous setup stage which was
|
|
|
|
|
* specified by $nextTeardown.
|
|
|
|
|
*
|
|
|
|
|
* @param ScopedCallback|null $nextTeardown
|
|
|
|
|
* @return ScopedCallback
|
|
|
|
|
*/
|
|
|
|
|
public function staticSetup( $nextTeardown = null ) {
|
|
|
|
|
// A note on coding style:
|
|
|
|
|
|
|
|
|
|
// The general idea here is to keep setup code together with
|
|
|
|
|
// corresponding teardown code, in a fine-grained manner. We have two
|
|
|
|
|
// arrays: $setup and $teardown. The code snippets in the $setup array
|
|
|
|
|
// are executed at the end of the method, before it returns, and the
|
|
|
|
|
// code snippets in the $teardown array are executed in reverse order
|
2016-10-12 05:36:03 +00:00
|
|
|
// when the Wikimedia\ScopedCallback object is consumed.
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
|
|
|
|
|
// Because it is a common operation to save, set and restore global
|
|
|
|
|
// variables, we have an additional convention: when the array key of
|
|
|
|
|
// $setup is a string, the string is taken to be the name of the global
|
|
|
|
|
// variable, and the element value is taken to be the desired new value.
|
|
|
|
|
|
|
|
|
|
// It's acceptable to just do the setup immediately, instead of adding
|
|
|
|
|
// a closure to $setup, except when the setup action depends on global
|
|
|
|
|
// variable initialisation being done first. In this case, you have to
|
|
|
|
|
// append a closure to $setup after the global variable is appended.
|
|
|
|
|
|
|
|
|
|
// When you add to setup functions in this class, please keep associated
|
|
|
|
|
// setup and teardown actions together in the source code, and please
|
|
|
|
|
// add comments explaining why the setup action is necessary.
|
|
|
|
|
|
|
|
|
|
$setup = [];
|
|
|
|
|
$teardown = [];
|
|
|
|
|
|
|
|
|
|
$teardown[] = $this->markSetupDone( 'staticSetup' );
|
|
|
|
|
|
|
|
|
|
// Some settings which influence HTML output
|
|
|
|
|
$setup['wgSitename'] = 'MediaWiki';
|
2021-12-03 00:41:33 +00:00
|
|
|
$setup['wgMetaNamespace'] = "TestWiki";
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$setup['wgServer'] = 'http://example.org';
|
|
|
|
|
$setup['wgServerName'] = 'example.org';
|
|
|
|
|
$setup['wgScriptPath'] = '';
|
|
|
|
|
$setup['wgScript'] = '/index.php';
|
|
|
|
|
$setup['wgResourceBasePath'] = '';
|
|
|
|
|
$setup['wgStylePath'] = '/skins';
|
|
|
|
|
$setup['wgExtensionAssetsPath'] = '/extensions';
|
|
|
|
|
$setup['wgArticlePath'] = '/wiki/$1';
|
|
|
|
|
$setup['wgActionPaths'] = [];
|
|
|
|
|
$setup['wgVariantArticlePath'] = false;
|
|
|
|
|
$setup['wgUploadNavigationUrl'] = false;
|
|
|
|
|
$setup['wgCapitalLinks'] = true;
|
|
|
|
|
$setup['wgNoFollowLinks'] = true;
|
|
|
|
|
$setup['wgNoFollowDomainExceptions'] = [ 'no-nofollow.org' ];
|
|
|
|
|
$setup['wgExternalLinkTarget'] = false;
|
|
|
|
|
$setup['wgLocaltimezone'] = 'UTC';
|
|
|
|
|
$setup['wgDisableLangConversion'] = false;
|
|
|
|
|
$setup['wgDisableTitleConversion'] = false;
|
2020-09-17 00:31:54 +00:00
|
|
|
$setup['wgUsePigLatinVariant'] = false;
|
2021-02-06 19:40:52 +00:00
|
|
|
$reset = static function () {
|
2020-11-25 04:35:49 +00:00
|
|
|
// Reset to follow changes to $wgDisable*Conversion
|
|
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'LanguageConverterFactory' );
|
|
|
|
|
};
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
|
|
|
|
|
// "extra language links"
|
|
|
|
|
// see https://gerrit.wikimedia.org/r/111390
|
|
|
|
|
$setup['wgExtraInterlanguageLinkPrefixes'] = [ 'mul' ];
|
|
|
|
|
|
2020-07-24 04:41:09 +00:00
|
|
|
// Parsoid settings for testing
|
|
|
|
|
$setup['wgParsoidSettings'] = [
|
|
|
|
|
'nativeGalleryEnabled' => true,
|
|
|
|
|
];
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// All FileRepo changes should be done here by injecting services,
|
|
|
|
|
// there should be no need to change global variables.
|
2019-05-01 12:54:54 +00:00
|
|
|
MediaWikiServices::getInstance()->disableService( 'RepoGroup' );
|
|
|
|
|
MediaWikiServices::getInstance()->redefineService( 'RepoGroup',
|
|
|
|
|
function () {
|
|
|
|
|
return $this->createRepoGroup();
|
|
|
|
|
}
|
|
|
|
|
);
|
2021-02-06 19:40:52 +00:00
|
|
|
$teardown[] = static function () {
|
2019-05-01 12:54:54 +00:00
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'RepoGroup' );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Set up null lock managers
|
|
|
|
|
$setup['wgLockManagers'] = [ [
|
2013-02-14 11:22:13 +00:00
|
|
|
'name' => 'fsLockManager',
|
2018-01-13 00:02:09 +00:00
|
|
|
'class' => NullLockManager::class,
|
2016-02-17 09:09:32 +00:00
|
|
|
], [
|
2013-02-14 11:22:13 +00:00
|
|
|
'name' => 'nullLockManager',
|
2018-01-13 00:02:09 +00:00
|
|
|
'class' => NullLockManager::class,
|
2016-02-17 09:09:32 +00:00
|
|
|
] ];
|
2021-02-06 19:40:52 +00:00
|
|
|
$reset = static function () {
|
2019-08-15 18:07:36 +00:00
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'LockManagerGroupFactory' );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
};
|
|
|
|
|
$setup[] = $reset;
|
|
|
|
|
$teardown[] = $reset;
|
|
|
|
|
|
|
|
|
|
// This allows article insertion into the prefixed DB
|
|
|
|
|
$setup['wgDefaultExternalStore'] = false;
|
|
|
|
|
|
|
|
|
|
// This might slightly reduce memory usage
|
|
|
|
|
$setup['wgAdaptiveMessageCache'] = true;
|
|
|
|
|
|
|
|
|
|
// This is essential and overrides disabling of database messages in TestSetup
|
|
|
|
|
$setup['wgUseDatabaseMessages'] = true;
|
2021-02-06 19:40:52 +00:00
|
|
|
$reset = static function () {
|
2019-04-08 15:21:49 +00:00
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'MessageCache' );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
};
|
|
|
|
|
$setup[] = $reset;
|
|
|
|
|
$teardown[] = $reset;
|
|
|
|
|
|
|
|
|
|
// It's not necessary to actually convert any files
|
|
|
|
|
$setup['wgSVGConverter'] = 'null';
|
|
|
|
|
$setup['wgSVGConverters'] = [ 'null' => 'echo "1">$output' ];
|
|
|
|
|
|
|
|
|
|
// Fake constant timestamp
|
2021-04-30 22:30:46 +00:00
|
|
|
MediaWikiServices::getInstance()->getHookContainer()->register(
|
|
|
|
|
'ParserGetVariableValueTs',
|
|
|
|
|
function ( $parser, &$ts ) {
|
|
|
|
|
$ts = $this->getFakeTimestamp();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
);
|
2020-04-14 17:56:55 +00:00
|
|
|
|
2021-02-06 19:40:52 +00:00
|
|
|
$teardown[] = static function () {
|
2021-04-30 22:30:46 +00:00
|
|
|
MediaWikiServices::getInstance()->getHookContainer()->clear( 'ParserGetVariableValueTs' );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$this->appendNamespaceSetup( $setup, $teardown );
|
|
|
|
|
|
|
|
|
|
// Set up interwikis and append teardown function
|
2020-12-18 22:32:27 +00:00
|
|
|
$this->appendInterwikiSetup( $setup, $teardown );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
|
|
|
|
|
// Set up a mock MediaHandlerFactory
|
|
|
|
|
MediaWikiServices::getInstance()->disableService( 'MediaHandlerFactory' );
|
|
|
|
|
MediaWikiServices::getInstance()->redefineService(
|
|
|
|
|
'MediaHandlerFactory',
|
2021-02-07 13:10:36 +00:00
|
|
|
static function ( MediaWikiServices $services ) {
|
2022-04-27 15:42:24 +00:00
|
|
|
$handlers = $services->getMainConfig()->get( MainConfigNames::ParserTestMediaHandlers );
|
2021-03-31 16:50:45 +00:00
|
|
|
return new MediaHandlerFactory(
|
|
|
|
|
new NullLogger(),
|
|
|
|
|
$handlers
|
|
|
|
|
);
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
}
|
|
|
|
|
);
|
2021-02-06 19:40:52 +00:00
|
|
|
$teardown[] = static function () {
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'MediaHandlerFactory' );
|
|
|
|
|
};
|
|
|
|
|
|
2017-02-20 23:45:58 +00:00
|
|
|
// SqlBagOStuff broke when using temporary tables on r40209 (T17892).
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// It seems to have been fixed since (r55079?), but regressed at some point before r85701.
|
|
|
|
|
// This works around it for now...
|
|
|
|
|
global $wgObjectCaches;
|
|
|
|
|
$setup['wgObjectCaches'] = [ CACHE_DB => $wgObjectCaches['hash'] ] + $wgObjectCaches;
|
|
|
|
|
if ( isset( ObjectCache::$instances[CACHE_DB] ) ) {
|
|
|
|
|
$savedCache = ObjectCache::$instances[CACHE_DB];
|
|
|
|
|
ObjectCache::$instances[CACHE_DB] = new HashBagOStuff;
|
2021-02-06 19:40:52 +00:00
|
|
|
$teardown[] = static function () use ( $savedCache ) {
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
ObjectCache::$instances[CACHE_DB] = $savedCache;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$teardown[] = $this->executeSetupSnippets( $setup );
|
|
|
|
|
|
|
|
|
|
// Schedule teardown snippets in reverse order
|
|
|
|
|
return $this->createTeardownObject( $teardown, $nextTeardown );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function appendNamespaceSetup( &$setup, &$teardown ) {
|
|
|
|
|
// Add a namespace shadowing a interwiki link, to test
|
2017-02-20 23:45:58 +00:00
|
|
|
// proper precedence when resolving links. (T53680)
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$setup['wgExtraNamespaces'] = [
|
|
|
|
|
100 => 'MemoryAlpha',
|
|
|
|
|
101 => 'MemoryAlpha_talk'
|
|
|
|
|
];
|
2018-08-05 08:36:32 +00:00
|
|
|
// Changing wgExtraNamespaces invalidates caches in NamespaceInfo and any live Language
|
|
|
|
|
// object, both on setup and teardown
|
2021-02-06 19:40:52 +00:00
|
|
|
$reset = static function () {
|
2022-03-11 22:54:37 +00:00
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'MainConfig' );
|
2018-08-05 08:36:32 +00:00
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'NamespaceInfo' );
|
2022-03-11 22:54:37 +00:00
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'LanguageFactory' );
|
|
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'ContentLanguage' );
|
|
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
|
|
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'LanguageConverterFactory' );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
};
|
|
|
|
|
$setup[] = $reset;
|
|
|
|
|
$teardown[] = $reset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a RepoGroup object appropriate for the current configuration
|
|
|
|
|
* @return RepoGroup
|
|
|
|
|
*/
|
|
|
|
|
protected function createRepoGroup() {
|
|
|
|
|
if ( $this->uploadDir ) {
|
|
|
|
|
if ( $this->fileBackendName ) {
|
|
|
|
|
throw new MWException( 'You cannot specify both use-filebackend and upload-dir' );
|
|
|
|
|
}
|
|
|
|
|
$backend = new FSFileBackend( [
|
2013-02-14 11:22:13 +00:00
|
|
|
'name' => 'local-backend',
|
2021-12-21 00:47:14 +00:00
|
|
|
'wikiId' => WikiMap::getCurrentWikiId(),
|
2016-09-19 01:39:59 +00:00
|
|
|
'basePath' => $this->uploadDir,
|
|
|
|
|
'tmpDirectory' => wfTempDir()
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
] );
|
|
|
|
|
} elseif ( $this->fileBackendName ) {
|
|
|
|
|
global $wgFileBackends;
|
|
|
|
|
$name = $this->fileBackendName;
|
|
|
|
|
$useConfig = false;
|
|
|
|
|
foreach ( $wgFileBackends as $conf ) {
|
|
|
|
|
if ( $conf['name'] === $name ) {
|
|
|
|
|
$useConfig = $conf;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( $useConfig === false ) {
|
|
|
|
|
throw new MWException( "Unable to find file backend \"$name\"" );
|
|
|
|
|
}
|
|
|
|
|
$useConfig['name'] = 'local-backend'; // swap name
|
|
|
|
|
unset( $useConfig['lockManager'] );
|
|
|
|
|
$class = $useConfig['class'];
|
2022-06-01 21:19:57 +00:00
|
|
|
// @phan-suppress-next-line PhanInvalidFQSENInClasslike
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$backend = new $class( $useConfig );
|
|
|
|
|
} else {
|
|
|
|
|
# Replace with a mock. We do not care about generating real
|
|
|
|
|
# files on the filesystem, just need to expose the file
|
|
|
|
|
# informations.
|
|
|
|
|
$backend = new MockFileBackend( [
|
|
|
|
|
'name' => 'local-backend',
|
2021-12-21 00:47:14 +00:00
|
|
|
'wikiId' => WikiMap::getCurrentWikiId()
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
] );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
|
2021-08-13 11:46:31 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
return new RepoGroup(
|
|
|
|
|
[
|
2018-01-13 00:02:09 +00:00
|
|
|
'class' => MockLocalRepo::class,
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
'name' => 'local',
|
|
|
|
|
'url' => 'http://example.com/images',
|
|
|
|
|
'hashLevels' => 2,
|
|
|
|
|
'transformVia404' => false,
|
|
|
|
|
'backend' => $backend
|
|
|
|
|
],
|
2019-05-01 12:54:54 +00:00
|
|
|
[],
|
2021-08-13 11:46:31 +00:00
|
|
|
$services->getMainWANObjectCache(),
|
|
|
|
|
$services->getMimeAnalyzer()
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute an array in which elements with integer keys are taken to be
|
|
|
|
|
* callable objects, and other elements are taken to be global variable
|
|
|
|
|
* set operations, with the key giving the variable name and the value
|
|
|
|
|
* giving the new global variable value. A closure is returned which, when
|
|
|
|
|
* executed, sets the global variables back to the values they had before
|
|
|
|
|
* this function was called.
|
|
|
|
|
*
|
|
|
|
|
* @see staticSetup
|
|
|
|
|
*
|
|
|
|
|
* @param array $setup
|
|
|
|
|
* @return closure
|
|
|
|
|
*/
|
|
|
|
|
protected function executeSetupSnippets( $setup ) {
|
|
|
|
|
$saved = [];
|
|
|
|
|
foreach ( $setup as $name => $value ) {
|
|
|
|
|
if ( is_int( $name ) ) {
|
|
|
|
|
$value();
|
|
|
|
|
} else {
|
2017-10-06 22:17:58 +00:00
|
|
|
$saved[$name] = $GLOBALS[$name] ?? null;
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$GLOBALS[$name] = $value;
|
|
|
|
|
}
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
return function () use ( $saved ) {
|
|
|
|
|
$this->executeSetupSnippets( $saved );
|
|
|
|
|
};
|
|
|
|
|
}
|
2012-01-09 22:33:00 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
/**
|
|
|
|
|
* Take a setup array in the same format as the one given to
|
|
|
|
|
* executeSetupSnippets(), and return a ScopedCallback which, when consumed,
|
|
|
|
|
* executes the snippets in the setup array in reverse order. This is used
|
|
|
|
|
* to create "teardown objects" for the public API.
|
|
|
|
|
*
|
|
|
|
|
* @see staticSetup
|
|
|
|
|
*
|
|
|
|
|
* @param array $teardown The snippet array
|
2017-08-11 16:09:41 +00:00
|
|
|
* @param ScopedCallback|null $nextTeardown A ScopedCallback to consume
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* @return ScopedCallback
|
|
|
|
|
*/
|
2020-12-21 22:30:52 +00:00
|
|
|
protected function createTeardownObject(
|
|
|
|
|
array $teardown, ?ScopedCallback $nextTeardown = null
|
|
|
|
|
) {
|
2017-06-26 16:35:31 +00:00
|
|
|
return new ScopedCallback( function () use ( $teardown, $nextTeardown ) {
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// Schedule teardown snippets in reverse order
|
|
|
|
|
$teardown = array_reverse( $teardown );
|
|
|
|
|
|
|
|
|
|
$this->executeSetupSnippets( $teardown );
|
|
|
|
|
if ( $nextTeardown ) {
|
|
|
|
|
ScopedCallback::consume( $nextTeardown );
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set a setupDone flag to indicate that setup has been done, and return
|
|
|
|
|
* the teardown closure. If the flag was already set, throw an exception.
|
|
|
|
|
*
|
|
|
|
|
* @param string $funcName The setup function name
|
|
|
|
|
* @return closure
|
|
|
|
|
*/
|
|
|
|
|
protected function markSetupDone( $funcName ) {
|
|
|
|
|
if ( $this->setupDone[$funcName] ) {
|
|
|
|
|
throw new MWException( "$funcName is already done" );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$this->setupDone[$funcName] = true;
|
|
|
|
|
return function () use ( $funcName ) {
|
|
|
|
|
$this->setupDone[$funcName] = false;
|
|
|
|
|
};
|
|
|
|
|
}
|
2014-07-21 02:35:50 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
/**
|
2019-11-03 04:42:01 +00:00
|
|
|
* Ensure one of the given setup stages has been done, throw an exception otherwise.
|
2017-09-09 20:47:04 +00:00
|
|
|
* @param string $funcName
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
*/
|
2020-12-23 18:52:12 +00:00
|
|
|
protected function checkSetupDone( string $funcName ) {
|
|
|
|
|
if ( !$this->setupDone[$funcName] ) {
|
|
|
|
|
throw new MWException( "$funcName must be called before calling " . wfGetCaller() );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
2016-04-07 05:20:38 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
/**
|
|
|
|
|
* Determine whether a particular setup function has been run
|
|
|
|
|
*
|
|
|
|
|
* @param string $funcName
|
2017-08-20 11:20:59 +00:00
|
|
|
* @return bool
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
*/
|
|
|
|
|
public function isSetupDone( $funcName ) {
|
2017-10-06 22:17:58 +00:00
|
|
|
return $this->setupDone[$funcName] ?? false;
|
2013-05-20 13:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Insert hardcoded interwiki in the lookup table.
|
|
|
|
|
*
|
|
|
|
|
* This function insert a set of well known interwikis that are used in
|
2020-12-18 22:32:27 +00:00
|
|
|
* the parser tests. We use the $wgInterwikiCache mechanism to completely
|
|
|
|
|
* replace any other lookup. (Note that the InterwikiLoadPrefix hook
|
|
|
|
|
* isn't used because it doesn't alter the result of
|
|
|
|
|
* Interwiki::getAllPrefixes() and so is incompatible with some users,
|
|
|
|
|
* including Parsoid.)
|
2021-01-16 19:44:17 +00:00
|
|
|
* @param array &$setup
|
|
|
|
|
* @param array &$teardown
|
2013-05-20 13:21:02 +00:00
|
|
|
*/
|
2020-12-18 22:32:27 +00:00
|
|
|
private function appendInterwikiSetup( &$setup, &$teardown ) {
|
|
|
|
|
static $testInterwikis = [
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'local',
|
2021-10-14 00:32:35 +00:00
|
|
|
// This is a "local interwiki" (see wgLocalInterwikis elsewhere in this file)
|
|
|
|
|
'iw_url' => 'http://example.org/wiki/$1',
|
|
|
|
|
'iw_local' => 1,
|
2020-12-18 22:32:27 +00:00
|
|
|
],
|
2021-12-03 00:41:33 +00:00
|
|
|
// Local interwiki that matches a namespace name (T228616)
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'project',
|
2021-10-14 00:32:35 +00:00
|
|
|
// This is a "local interwiki" (see wgLocalInterwikis elsewhere in this file)
|
|
|
|
|
'iw_url' => 'http://example.org/wiki/$1',
|
|
|
|
|
'iw_local' => 1,
|
2021-12-03 00:41:33 +00:00
|
|
|
],
|
2020-12-18 22:32:27 +00:00
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'wikipedia',
|
|
|
|
|
'iw_url' => 'http://en.wikipedia.org/wiki/$1',
|
|
|
|
|
'iw_local' => 0,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'meatball',
|
|
|
|
|
// this has been updated in the live wikis, but the parser tests
|
|
|
|
|
// expect the old value
|
|
|
|
|
'iw_url' => 'http://www.usemod.com/cgi-bin/mb.pl?$1',
|
|
|
|
|
'iw_local' => 0,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'memoryalpha',
|
|
|
|
|
'iw_url' => 'http://www.memory-alpha.org/en/index.php/$1',
|
|
|
|
|
'iw_local' => 0,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'zh',
|
|
|
|
|
'iw_url' => 'http://zh.wikipedia.org/wiki/$1',
|
|
|
|
|
'iw_local' => 1,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'es',
|
|
|
|
|
'iw_url' => 'http://es.wikipedia.org/wiki/$1',
|
|
|
|
|
'iw_local' => 1,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'fr',
|
|
|
|
|
'iw_url' => 'http://fr.wikipedia.org/wiki/$1',
|
|
|
|
|
'iw_local' => 1,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'ru',
|
|
|
|
|
'iw_url' => 'http://ru.wikipedia.org/wiki/$1',
|
|
|
|
|
'iw_local' => 1,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'mi',
|
2021-10-14 00:32:35 +00:00
|
|
|
// This is a "local interwiki" (see wgLocalInterwikis elsewhere in this file)
|
|
|
|
|
'iw_url' => 'http://example.org/wiki/$1',
|
2020-12-18 22:32:27 +00:00
|
|
|
'iw_local' => 1,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'mul',
|
|
|
|
|
'iw_url' => 'http://wikisource.org/wiki/$1',
|
|
|
|
|
'iw_local' => 1,
|
|
|
|
|
],
|
2020-12-18 23:50:51 +00:00
|
|
|
// Additions from Parsoid
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'en',
|
2022-06-07 22:42:27 +00:00
|
|
|
'iw_url' => '//en.wikipedia.org/wiki/$1',
|
|
|
|
|
'iw_local' => 1
|
2020-12-18 23:50:51 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'stats',
|
|
|
|
|
'iw_url' => 'https://stats.wikimedia.org/$1',
|
|
|
|
|
'iw_local' => 1,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'gerrit',
|
|
|
|
|
'iw_url' => 'https://gerrit.wikimedia.org/$1',
|
|
|
|
|
'iw_local' => 1,
|
|
|
|
|
],
|
|
|
|
|
// Deliberately missing a $1 in the URL to exercise a common
|
|
|
|
|
// misconfiguration.
|
|
|
|
|
[
|
|
|
|
|
'iw_prefix' => 'wikinvest',
|
|
|
|
|
'iw_url' => 'https://meta.wikimedia.org/wiki/Interwiki_map/discontinued#Wikinvest',
|
|
|
|
|
'iw_local' => 1,
|
|
|
|
|
],
|
2020-12-18 22:32:27 +00:00
|
|
|
];
|
|
|
|
|
// When running from parserTests.php, database setup happens *after*
|
|
|
|
|
// interwiki setup, and that changes the wiki id. In order to avoid
|
|
|
|
|
// breaking the interwiki cache, use 'global scope' for the interwiki
|
|
|
|
|
// lookup.
|
|
|
|
|
$GLOBAL_SCOPE = 2; // See docs for $wgInterwikiScopes
|
|
|
|
|
$setup['wgInterwikiScopes'] = $GLOBAL_SCOPE;
|
|
|
|
|
$setup['wgInterwikiCache'] =
|
|
|
|
|
ClassicInterwikiLookup::buildCdbHash( $testInterwikis, $GLOBAL_SCOPE );
|
2021-02-06 19:40:52 +00:00
|
|
|
$reset = static function () {
|
2020-12-18 22:32:27 +00:00
|
|
|
// Reset the service in case any other tests already cached some prefixes.
|
2018-04-10 21:05:31 +00:00
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'InterwikiLookup' );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
};
|
2020-12-18 22:32:27 +00:00
|
|
|
$setup[] = $reset;
|
|
|
|
|
$teardown[] = $reset;
|
|
|
|
|
|
|
|
|
|
// This affects title normalization in links. It invalidates
|
|
|
|
|
// MediaWikiTitleCodec objects.
|
2021-10-14 00:32:35 +00:00
|
|
|
// These interwikis should have 'iw_url' that matches wgServer.
|
2021-12-03 00:41:33 +00:00
|
|
|
$setup['wgLocalInterwikis'] = [ 'local', 'project', 'mi' ];
|
2020-12-18 22:32:27 +00:00
|
|
|
$reset = function () {
|
|
|
|
|
$this->resetTitleServices();
|
|
|
|
|
};
|
|
|
|
|
$setup[] = $reset;
|
|
|
|
|
$teardown[] = $reset;
|
2013-08-22 18:38:50 +00:00
|
|
|
}
|
|
|
|
|
|
2016-04-25 05:41:32 +00:00
|
|
|
/**
|
|
|
|
|
* Reset the Title-related services that need resetting
|
|
|
|
|
* for each test
|
2019-04-12 09:49:59 +00:00
|
|
|
*
|
|
|
|
|
* @todo We need to reset all services on every test
|
2016-04-25 05:41:32 +00:00
|
|
|
*/
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
private function resetTitleServices() {
|
2016-04-25 05:41:32 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
$services->resetServiceForTesting( 'TitleFormatter' );
|
|
|
|
|
$services->resetServiceForTesting( 'TitleParser' );
|
|
|
|
|
$services->resetServiceForTesting( '_MediaWikiTitleCodec' );
|
Add LinkRenderer (rewrite of Linker::link())
This is a rewrite of Linker::link() to a non-static, LinkTarget-based
interface. Users of plain Linker::link() with no options can use the
LinkRenderer instance provided by MediaWikiServices. Others that
have specific options should create and configure their own instance,
which can be used to create as many links as necessary.
The main entrypoints for making links are:
* ->makeLink( $target, $text, $attribs, $query );
* ->makeKnownLink( $target, $text, $attribs, $query );
* ->makeBrokenLink( $target, $text, $attribs, $query );
The order of the parameters are the same as Linker::link(), except
$options are now part of the LinkRenderer instance, and
known/broken status requires calling the function explicitly.
Additionally, instead of passing in raw $html for the link text, the
$text parameter will automatically be escaped unless it is specially
marked as safe HTML using the MediaWiki\Linker\HtmlArmor class.
The LinkBegin and LinkEnd hooks are now deprecated, but still function
for backwards-compatability. Clients should migrate to the nearly-
equivalent LinkRendererBegin and LinkRendererEnd hooks.
The main differences between the hooks are:
* Passing HtmlPageLinkRenderer object instead of deprecated DummyLinker
* Using LinkTarget instead of Title
* Begin hook can no longer change known/broken status of link. Use the
TitleIsAlwaysKnown hook for that.
* $options are no longer passed, they can be read (but shouldn't be
modified!) from the LinkRenderer object.
Bug: T469
Change-Id: I057cc86ae6404a080aa3c8e0e956ecbb10a897d5
2016-04-21 20:13:21 +00:00
|
|
|
$services->resetServiceForTesting( 'LinkRenderer' );
|
|
|
|
|
$services->resetServiceForTesting( 'LinkRendererFactory' );
|
2019-04-12 09:49:59 +00:00
|
|
|
$services->resetServiceForTesting( 'NamespaceInfo' );
|
2020-09-22 18:16:23 +00:00
|
|
|
$services->resetServiceForTesting( 'SpecialPageFactory' );
|
2016-04-25 05:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-09 22:33:00 +00:00
|
|
|
/**
|
|
|
|
|
* Remove last character if it is a newline
|
2014-04-17 18:43:42 +00:00
|
|
|
* @param string $s
|
2014-08-25 16:50:35 +00:00
|
|
|
* @return string
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
2013-02-12 21:32:09 +00:00
|
|
|
public static function chomp( $s ) {
|
2012-01-09 22:33:00 +00:00
|
|
|
if ( substr( $s, -1 ) === "\n" ) {
|
|
|
|
|
return substr( $s, 0, -1 );
|
2013-02-14 11:22:13 +00:00
|
|
|
} else {
|
2012-01-09 22:33:00 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Run a series of tests listed in the given text files.
|
|
|
|
|
* Each test consists of a brief description, wikitext input,
|
|
|
|
|
* and the expected HTML output.
|
|
|
|
|
*
|
|
|
|
|
* Prints status updates on stdout and counts up the total
|
|
|
|
|
* number and percentage of passed tests.
|
|
|
|
|
*
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* Handles all setup and teardown.
|
|
|
|
|
*
|
2014-04-17 18:43:42 +00:00
|
|
|
* @param array $filenames Array of strings
|
|
|
|
|
* @return bool True if passed all tests, false if any tests failed.
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
|
|
|
|
public function runTestsFromFiles( $filenames ) {
|
|
|
|
|
$ok = false;
|
2013-07-30 13:12:12 +00:00
|
|
|
|
2020-12-23 18:52:12 +00:00
|
|
|
$teardownGuard = null;
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$teardownGuard = $this->setupDatabase( $teardownGuard );
|
2020-12-23 18:52:12 +00:00
|
|
|
$teardownGuard = $this->staticSetup( $teardownGuard );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$teardownGuard = $this->setupUploads( $teardownGuard );
|
2013-07-30 13:12:12 +00:00
|
|
|
|
2012-01-09 22:33:00 +00:00
|
|
|
$this->recorder->start();
|
|
|
|
|
try {
|
|
|
|
|
$ok = true;
|
|
|
|
|
|
|
|
|
|
foreach ( $filenames as $filename ) {
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$this->recorder->startSuite( $filename );
|
2022-05-14 05:06:03 +00:00
|
|
|
if ( $this->options['parsoid'] ) {
|
|
|
|
|
$ok = $this->runParsoidTests( $filename ) && $ok;
|
|
|
|
|
} else {
|
2022-05-20 20:42:25 +00:00
|
|
|
$ok = $this->runLegacyTests( $filename ) && $ok;
|
2022-05-14 05:06:03 +00:00
|
|
|
}
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$this->recorder->endSuite( $filename );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->recorder->report();
|
2013-02-14 11:22:13 +00:00
|
|
|
} catch ( DBError $e ) {
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$this->recorder->warning( $e->getMessage() );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
$this->recorder->end();
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
ScopedCallback::consume( $teardownGuard );
|
|
|
|
|
|
2012-01-09 22:33:00 +00:00
|
|
|
return $ok;
|
|
|
|
|
}
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
/**
|
|
|
|
|
* Determine whether the current parser has the hooks registered in it
|
|
|
|
|
* that are required by a file read by TestFileReader.
|
2017-09-09 20:47:04 +00:00
|
|
|
* @param array $requirements
|
|
|
|
|
* @return bool
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
*/
|
|
|
|
|
public function meetsRequirements( $requirements ) {
|
|
|
|
|
foreach ( $requirements as $requirement ) {
|
2022-06-01 21:19:57 +00:00
|
|
|
$ok = true;
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
switch ( $requirement['type'] ) {
|
2017-12-11 03:07:50 +00:00
|
|
|
case 'hook':
|
|
|
|
|
$ok = $this->requireHook( $requirement['name'] );
|
|
|
|
|
break;
|
|
|
|
|
case 'functionHook':
|
|
|
|
|
$ok = $this->requireFunctionHook( $requirement['name'] );
|
|
|
|
|
break;
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
}
|
|
|
|
|
if ( !$ok ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-05-20 20:42:25 +00:00
|
|
|
* Run the legacy parser tests from a single file. staticSetup() and
|
|
|
|
|
* setupDatabase() must have been called already.
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
*
|
2022-05-14 05:06:03 +00:00
|
|
|
* @param string $filename Test file name
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* @return bool True if passed all tests, false if any tests failed.
|
|
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
public function runLegacyTests( string $filename ): bool {
|
|
|
|
|
$mode = new ParserTestMode( 'legacy' );
|
|
|
|
|
$testFileInfo = TestFileReader::read( $filename,
|
|
|
|
|
static function ( $msg ) {
|
|
|
|
|
wfDeprecatedMsg( $msg, '1.35', false, false );
|
|
|
|
|
}
|
|
|
|
|
);
|
2022-05-14 05:06:03 +00:00
|
|
|
|
|
|
|
|
$this->checkSetupDone( 'staticSetup' );
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// If any requirements are not met, mark all tests from the file as skipped
|
2022-05-20 20:42:25 +00:00
|
|
|
$skipMessage = $this->getFileSkipMessage( true, $testFileInfo->fileOptions, $filename );
|
|
|
|
|
if ( $skipMessage !== null ) {
|
|
|
|
|
foreach ( $testFileInfo->testCases as $test ) {
|
|
|
|
|
$this->recorder->startTest( $test, $mode );
|
|
|
|
|
$this->recorder->skipped( $test, $mode, $skipMessage );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add articles
|
2022-05-20 20:42:25 +00:00
|
|
|
$teardown = $this->addArticles( $testFileInfo->articles );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
|
|
|
|
|
// Run tests
|
2022-05-20 20:42:25 +00:00
|
|
|
$ok = true;
|
|
|
|
|
$runner = $this;
|
|
|
|
|
foreach ( $testFileInfo->testCases as $test ) {
|
|
|
|
|
$result = $this->runTest( $test, $mode );
|
2022-06-03 21:44:26 +00:00
|
|
|
$ok = $ok && $result->isSuccess();
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-18 03:41:34 +00:00
|
|
|
// Clean up
|
2020-12-21 22:30:52 +00:00
|
|
|
ScopedCallback::consume( $teardown );
|
2020-08-18 03:41:34 +00:00
|
|
|
|
2012-01-09 22:33:00 +00:00
|
|
|
return $ok;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-14 05:06:03 +00:00
|
|
|
/**
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param bool $isLegacy
|
2022-05-14 05:06:03 +00:00
|
|
|
* @param array $fileOptions
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param string $filename
|
2022-05-14 05:06:03 +00:00
|
|
|
* @return string|null
|
|
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
public function getFileSkipMessage( bool $isLegacy, array $fileOptions, string $filename ): ?string {
|
|
|
|
|
$runnerOpts = $this->getOptions();
|
|
|
|
|
// Verify minimum version #
|
|
|
|
|
$testFormat = intval( $fileOptions['version'] ?? '1' );
|
|
|
|
|
if ( $testFormat < 2 ) {
|
|
|
|
|
throw new MWException(
|
|
|
|
|
"$filename needs an update. Support for the parserTest v1 file format was removed in MediaWiki 1.36"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-14 05:06:03 +00:00
|
|
|
// If any requirements are not met, mark all tests from the file as skipped
|
2022-05-20 20:42:25 +00:00
|
|
|
if ( !(
|
|
|
|
|
$isLegacy ||
|
|
|
|
|
isset( $fileOptions['parsoid-compatible'] ) ||
|
|
|
|
|
( $runnerOpts['parsoid'] ?? false )
|
|
|
|
|
) ) {
|
2022-05-14 05:06:03 +00:00
|
|
|
// Running files in Parsoid integrated mode is opt-in for now.
|
|
|
|
|
return 'not compatible with Parsoid integrated mode';
|
|
|
|
|
} elseif ( !$this->meetsRequirements( $fileOptions['requirements'] ?? [] ) ) {
|
|
|
|
|
return 'required extension not enabled';
|
|
|
|
|
} elseif ( ( $runnerOpts['testFile'] ?? $filename ) !== $filename ) {
|
|
|
|
|
return 'Not the requested test file';
|
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
public function getTestSkipMessage( ParserTest $test, ParserTestMode $mode ) {
|
|
|
|
|
if ( $test->wikitext === null ) {
|
|
|
|
|
// Note that /in theory/ we could have pure html2html tests
|
|
|
|
|
// with no wikitext section, but /in practice/ all tests
|
|
|
|
|
// include a wikitext section.
|
|
|
|
|
$test->error( "Test lacks wikitext section", $test->testName );
|
|
|
|
|
}
|
|
|
|
|
// Skip disabled / filtered tests
|
|
|
|
|
if ( isset( $test->options['disabled'] ) && !$this->runDisabled ) {
|
|
|
|
|
return "Test disabled";
|
|
|
|
|
}
|
|
|
|
|
$testFilter = [ 'regex' => $this->regex ];
|
|
|
|
|
if ( !$test->matchesFilter( $testFilter ) ) {
|
|
|
|
|
return "Test doesn't match filter";
|
|
|
|
|
}
|
|
|
|
|
// Skip parsoid-only tests if running in a legacy test mode
|
|
|
|
|
if ( $test->legacyHtml === null ) {
|
|
|
|
|
// A Parsoid-only test should have one of the following sections
|
|
|
|
|
if (
|
|
|
|
|
isset( $test->sections['html/parsoid'] ) ||
|
|
|
|
|
isset( $test->sections['html/parsoid+integrated'] ) ||
|
|
|
|
|
isset( $test->sections['html/parsoid+standalone'] ) ||
|
|
|
|
|
isset( $test->sections['wikitext/edited'] )
|
|
|
|
|
) {
|
|
|
|
|
if ( $mode->isLegacy() ) {
|
|
|
|
|
// Not an error, just skip this test if we're in
|
|
|
|
|
// legacy mode.
|
|
|
|
|
return "Parsoid-only test";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// This test lacks both a legacy html section and also
|
|
|
|
|
// any parsoid-specific html or wikitext/edited section.
|
|
|
|
|
$test->error( "Test lacks html section", $test->testName );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-25 21:46:58 +00:00
|
|
|
/**
|
|
|
|
|
* Compute valid test modes based on requested modes and file-enabled modes
|
|
|
|
|
* @param array $testModes
|
|
|
|
|
* @param array $fileOptions
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function computeValidTestModes( array $testModes, array $fileOptions ): array {
|
|
|
|
|
$modeRestriction = $fileOptions['parsoid-compatible'] ?? false;
|
|
|
|
|
if ( $modeRestriction !== false ) {
|
|
|
|
|
if ( is_string( $modeRestriction ) ) {
|
|
|
|
|
// shorthand
|
|
|
|
|
$modeRestriction = [ $modeRestriction ];
|
|
|
|
|
}
|
|
|
|
|
$testModes = array_values( array_intersect( $testModes, $modeRestriction ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $testModes;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-14 05:06:03 +00:00
|
|
|
/**
|
|
|
|
|
* Run the tests from a single file. staticSetup() and setupDatabase()
|
|
|
|
|
* must have been called already.
|
|
|
|
|
*
|
|
|
|
|
* @param string $filename Test file name
|
|
|
|
|
* @return bool True if passed all tests, false if any tests failed.
|
|
|
|
|
*/
|
|
|
|
|
public function runParsoidTests( string $filename ): bool {
|
2022-05-20 20:42:25 +00:00
|
|
|
$testFileInfo = TestFileReader::read( $filename,
|
2022-05-14 05:06:03 +00:00
|
|
|
static function ( $msg ) {
|
|
|
|
|
wfDeprecatedMsg( $msg, '1.35', false, false );
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2022-10-25 21:46:58 +00:00
|
|
|
// Intersect requested modes with test modes enabled in the file
|
|
|
|
|
$testModes = $this->computeValidTestModes(
|
|
|
|
|
$this->getRequestedTestModes(), $testFileInfo->fileOptions );
|
|
|
|
|
|
2022-05-14 05:06:03 +00:00
|
|
|
$this->checkSetupDone( 'staticSetup' );
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
// If any requirements are not met, mark all tests from the file as skipped
|
2022-10-25 21:46:58 +00:00
|
|
|
if ( !$testModes ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
$skipMode = new ParserTestMode( $testModes[0] );
|
2022-05-20 20:42:25 +00:00
|
|
|
$skipMessage = $this->getFileSkipMessage( false, $testFileInfo->fileOptions, $filename );
|
2022-05-14 05:06:03 +00:00
|
|
|
if ( $skipMessage !== null ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
foreach ( $testFileInfo->testCases as $test ) {
|
|
|
|
|
$this->recorder->startTest( $test, $skipMode );
|
|
|
|
|
$this->recorder->skipped( $test, $skipMode, $skipMessage );
|
2022-05-14 05:06:03 +00:00
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add articles
|
2022-05-20 20:42:25 +00:00
|
|
|
$teardown = $this->addArticles( $testFileInfo->articles );
|
2022-05-14 05:06:03 +00:00
|
|
|
|
|
|
|
|
// Run tests
|
|
|
|
|
$ok = true;
|
|
|
|
|
$runner = $this;
|
|
|
|
|
$testFilter = [ 'regex' => $this->regex ];
|
|
|
|
|
foreach ( $testFileInfo->testCases as $t ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
$t->testAllModes( $t->computeTestModes( $testModes ), $this->options,
|
|
|
|
|
function ( ParserTest $test, string $modeStr, array $options ) use ( $runner, $t, &$ok ) {
|
2022-05-14 05:06:03 +00:00
|
|
|
// $test could be a clone of $t
|
|
|
|
|
// Ensure that updates to knownFailures in $test are reflected in $t
|
|
|
|
|
$test->knownFailures = &$t->knownFailures;
|
2022-05-20 20:42:25 +00:00
|
|
|
$mode = new ParserTestMode( $modeStr, $test->changetree );
|
|
|
|
|
if ( $modeStr === 'selser' && $test->changetree === null ) {
|
2022-05-14 05:06:03 +00:00
|
|
|
// This is an auto-edit test with either a CLI changetree
|
|
|
|
|
// or a change tree that should be generated
|
2022-05-20 20:42:25 +00:00
|
|
|
$mode = new ParserTestMode( 'selser-auto', json_decode( $runner->options['changetree'] ) );
|
2022-07-19 01:04:31 +00:00
|
|
|
$result = $this->runTest( $test, $mode );
|
|
|
|
|
|
|
|
|
|
// FIXME: Test.php in Parsoid doesn't know which tests are being
|
|
|
|
|
// skipped for what reason. For now, prevent crashers on skipped tests
|
|
|
|
|
// by matching expectations of Test.php::isDuplicateChangeTree(..)
|
|
|
|
|
if ( $result->expected === 'SKIP' ) {
|
|
|
|
|
// Make sure change tree is not null for skipped selser tests
|
|
|
|
|
$test->changetree = [];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$result = $this->runTest( $test, $mode );
|
2022-05-14 05:06:03 +00:00
|
|
|
}
|
2022-06-03 21:44:26 +00:00
|
|
|
$ok = $ok && $result->isSuccess();
|
2022-05-14 05:06:03 +00:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $this->options['updateKnownFailures'] ) {
|
|
|
|
|
$this->updateKnownFailures( $testFileInfo );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clean up
|
|
|
|
|
ScopedCallback::consume( $teardown );
|
|
|
|
|
|
|
|
|
|
return $ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update known failures JSON file for the parser tests file
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param TestFileReader $testFileInfo
|
2022-05-14 05:06:03 +00:00
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
public function updateKnownFailures( TestFileReader $testFileInfo ): void {
|
2022-05-14 05:06:03 +00:00
|
|
|
$testKnownFailures = [];
|
|
|
|
|
foreach ( $testFileInfo->testCases as $t ) {
|
2022-06-01 21:19:57 +00:00
|
|
|
if ( $t->knownFailures && $t->testName ) {
|
|
|
|
|
// @phan-suppress-next-line PhanTypeMismatchDimAssignment False positive
|
2022-05-14 05:06:03 +00:00
|
|
|
$testKnownFailures[$t->testName] = $t->knownFailures;
|
|
|
|
|
// FIXME: This reduces noise when updateKnownFailures is used
|
|
|
|
|
// with a subset of test modes. But, this also mixes up the selser
|
|
|
|
|
// test results with non-selser ones.
|
|
|
|
|
// ksort( $testKnownFailures[$t->testName] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Sort, otherwise, titles get added above based on the first
|
|
|
|
|
// failing mode, which can make diffs harder to verify when
|
|
|
|
|
// failing modes change.
|
|
|
|
|
ksort( $testKnownFailures );
|
2022-07-28 17:17:53 +00:00
|
|
|
$contents = FormatJson::encode( $testKnownFailures, "\t", FormatJson::ALL_OK ) . "\n";
|
2022-05-14 05:06:03 +00:00
|
|
|
|
|
|
|
|
if ( file_exists( $testFileInfo->knownFailuresPath ) ) {
|
|
|
|
|
$old = file_get_contents( $testFileInfo->knownFailuresPath );
|
|
|
|
|
} else {
|
|
|
|
|
$old = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $testFileInfo->knownFailuresPath && $old !== $contents ) {
|
2022-07-27 18:18:17 +00:00
|
|
|
$this->recorder->warning( "Updating known failures file: {$testFileInfo->knownFailuresPath}" );
|
2022-05-14 05:06:03 +00:00
|
|
|
file_put_contents( $testFileInfo->knownFailuresPath, $contents );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-27 21:28:14 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $wikitext
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function getRevRecordProperties( string $wikitext ): array {
|
|
|
|
|
return [
|
|
|
|
|
'pageid' => 187, // Some random fake page id
|
|
|
|
|
'revid' => 1337, // see Parser::getRevisionId()
|
|
|
|
|
'timestamp' => $this->getFakeTimestamp(),
|
|
|
|
|
'wikitext' => $wikitext
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a mutable rev record for test use.
|
|
|
|
|
*
|
|
|
|
|
* @param Title $title
|
|
|
|
|
* @param User $user
|
|
|
|
|
* @param array $revProps
|
|
|
|
|
* @return RevisionRecord
|
|
|
|
|
*/
|
|
|
|
|
private function createRevRecord( Title $title, User $user, array $revProps ): RevisionRecord {
|
|
|
|
|
$content = new WikitextContent( $revProps['wikitext'] );
|
|
|
|
|
$title = Title::newFromRow( (object)[
|
|
|
|
|
'page_id' => $revProps['pageid'],
|
|
|
|
|
'page_len' => $content->getSize(),
|
|
|
|
|
'page_latest' => $revProps['revid'],
|
|
|
|
|
'page_namespace' => $title->getNamespace(),
|
|
|
|
|
'page_title' => $title->getDBkey(),
|
|
|
|
|
'page_is_redirect' => 0
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
$revRecord = new MutableRevisionRecord( $title );
|
|
|
|
|
$revRecord->setContent( SlotRecord::MAIN, $content )
|
|
|
|
|
->setUser( $user )
|
|
|
|
|
->setTimestamp( strval( $revProps['timestamp'] ) )
|
|
|
|
|
->setPageId( $title->getArticleID() )
|
|
|
|
|
->setId( $title->getLatestRevID() );
|
|
|
|
|
|
|
|
|
|
return $revRecord;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-09 22:33:00 +00:00
|
|
|
/**
|
2020-07-24 04:41:09 +00:00
|
|
|
* Shared code to initialize ParserOptions based on the $test object,
|
|
|
|
|
* used by both the legacy Parser and the Parsoid parser.
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTest $test
|
2020-07-24 04:41:09 +00:00
|
|
|
* @param callable $parserOptionsCallback A callback to create the
|
|
|
|
|
* initial ParserOptions object. This allows for some minor
|
|
|
|
|
* differences in how the legacy Parser and Parsoid create this.
|
|
|
|
|
* @return array An array of Title, ParserOptions, and integer revId.
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
private function setupParserOptions( ParserTest $test, callable $parserOptionsCallback ) {
|
2020-07-24 04:41:09 +00:00
|
|
|
$opts = $test->options;
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$context = RequestContext::getMain();
|
2022-08-27 21:28:14 +00:00
|
|
|
$wikitext = $test->wikitext;
|
|
|
|
|
'@phan-var string $wikitext'; // assert that this is not null
|
|
|
|
|
$revProps = $this->getRevRecordProperties( $wikitext );
|
2012-01-09 22:33:00 +00:00
|
|
|
$user = $context->getUser();
|
2019-07-04 10:01:31 +00:00
|
|
|
$title = isset( $opts['title'] )
|
|
|
|
|
? Title::newFromText( $opts['title'] )
|
|
|
|
|
: $this->defaultTitle;
|
|
|
|
|
|
2022-08-27 21:28:14 +00:00
|
|
|
$revRecord = null;
|
2019-07-04 10:01:31 +00:00
|
|
|
if ( isset( $opts['lastsavedrevision'] ) ) {
|
2022-08-27 21:28:14 +00:00
|
|
|
$revRecord = $this->createRevRecord( $title, $user, $revProps );
|
|
|
|
|
$revProps['rev'] = $revRecord;
|
2022-09-20 20:45:44 +00:00
|
|
|
// Increment timestamp so that parser tests can distinguish between
|
|
|
|
|
// ParserOptions source and RevisionRecord
|
|
|
|
|
$revProps['timestamp'] += 234;
|
2022-08-27 21:28:14 +00:00
|
|
|
}
|
2020-06-03 03:48:42 +00:00
|
|
|
|
2022-08-27 21:28:14 +00:00
|
|
|
$options = $parserOptionsCallback( $context, $title, $revProps );
|
2022-09-20 20:45:44 +00:00
|
|
|
$options->setTimestamp(
|
|
|
|
|
MWTimestamp::convert( TS_MW, $revProps['timestamp'] )
|
|
|
|
|
);
|
2022-08-27 21:28:14 +00:00
|
|
|
$options->setUserLang( $context->getLanguage() );
|
2020-06-03 03:48:42 +00:00
|
|
|
|
2022-08-27 21:28:14 +00:00
|
|
|
if ( isset( $opts['lastsavedrevision'] ) ) {
|
2020-06-03 03:48:42 +00:00
|
|
|
$oldCallback = $options->getCurrentRevisionRecordCallback();
|
|
|
|
|
$options->setCurrentRevisionRecordCallback(
|
2021-02-07 13:10:36 +00:00
|
|
|
static function ( Title $t, $parser = null ) use ( $title, $revRecord, $oldCallback ) {
|
2019-07-04 10:01:31 +00:00
|
|
|
if ( $t->equals( $title ) ) {
|
2020-06-03 03:48:42 +00:00
|
|
|
return $revRecord;
|
2019-07-04 10:01:31 +00:00
|
|
|
} else {
|
2020-05-29 06:46:30 +00:00
|
|
|
return $oldCallback( $t, $parser );
|
2019-07-04 10:01:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-27 05:57:55 +00:00
|
|
|
if ( isset( $opts['maxincludesize'] ) ) {
|
|
|
|
|
$options->setMaxIncludeSize( $opts['maxincludesize'] );
|
|
|
|
|
}
|
|
|
|
|
if ( isset( $opts['maxtemplatedepth'] ) ) {
|
|
|
|
|
$options->setMaxTemplateDepth( $opts['maxtemplatedepth'] );
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-27 21:28:14 +00:00
|
|
|
return [ $title, $options, $revProps['revid'] ];
|
2020-07-24 04:41:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a Parser object
|
|
|
|
|
*
|
|
|
|
|
* @return Parser
|
|
|
|
|
*/
|
|
|
|
|
public function getParser() {
|
|
|
|
|
$parserFactory = MediaWikiServices::getInstance()->getParserFactory();
|
|
|
|
|
$parser = $parserFactory->create(); // A fresh parser object.
|
|
|
|
|
ParserTestParserHook::setup( $parser );
|
|
|
|
|
return $parser;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
/**
|
|
|
|
|
* Run a given wikitext input through either the legacy wiki parser
|
|
|
|
|
* or Parsoid, depending on the given test mode, and compare the
|
|
|
|
|
* output against the expected results.
|
|
|
|
|
*
|
|
|
|
|
* @param ParserTest $test The test parameters
|
|
|
|
|
* @param ParserTestMode $mode The test mode
|
2022-06-07 22:35:32 +00:00
|
|
|
* @return ParserTestResult The test results.
|
2022-05-20 20:42:25 +00:00
|
|
|
*/
|
2022-06-07 22:35:32 +00:00
|
|
|
public function runTest( ParserTest $test, ParserTestMode $mode ): ParserTestResult {
|
2022-05-20 20:42:25 +00:00
|
|
|
if ( $this->getTestSkipMessage( $test, $mode ) ) {
|
2022-06-07 22:35:32 +00:00
|
|
|
return new ParserTestResult( $test, $mode, 'SKIP', 'SKIP' );
|
2022-05-20 20:42:25 +00:00
|
|
|
}
|
2022-06-03 21:44:26 +00:00
|
|
|
$this->recorder->startTest( $test, $mode );
|
|
|
|
|
$result = $mode->isLegacy() ?
|
|
|
|
|
$this->runLegacyTest( $test, $mode ) :
|
|
|
|
|
$this->runParsoidTest( $test, $mode );
|
|
|
|
|
if ( $result === false ) {
|
|
|
|
|
$this->recorder->skipped( $test, $mode, 'SKIP' );
|
2022-06-07 22:35:32 +00:00
|
|
|
return new ParserTestResult( $test, $mode, 'SKIP', 'SKIP' );
|
2022-05-20 20:42:25 +00:00
|
|
|
} else {
|
2022-06-03 21:44:26 +00:00
|
|
|
$this->recorder->record( $result );
|
2022-06-07 22:35:32 +00:00
|
|
|
return $result;
|
2022-05-20 20:42:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 04:41:09 +00:00
|
|
|
/**
|
|
|
|
|
* Run a given wikitext input through a freshly-constructed instance
|
|
|
|
|
* of the legacy wiki parser, and compare the output against the expected
|
|
|
|
|
* results.
|
|
|
|
|
*
|
|
|
|
|
* Prints status and explanatory messages to stdout.
|
|
|
|
|
*
|
|
|
|
|
* staticSetup() and setupWikiData() must be called before this function
|
|
|
|
|
* is entered.
|
|
|
|
|
*
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTest $test The test parameters
|
|
|
|
|
* @param ParserTestMode $mode The test mode
|
2020-07-24 04:41:09 +00:00
|
|
|
* @return ParserTestResult|false false if skipped
|
|
|
|
|
*/
|
2022-07-09 20:19:27 +00:00
|
|
|
public function runLegacyTest( ParserTest $test, ParserTestMode $mode ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
$desc = ( $test->comment ?? '' ) . $test->testName;
|
|
|
|
|
wfDebug( __METHOD__ . ": running $desc" );
|
|
|
|
|
$opts = $test->options;
|
2020-07-24 04:41:09 +00:00
|
|
|
if ( isset( $opts['preprocessor'] ) && $opts['preprocessor'] !== 'Preprocessor_Hash' ) {
|
|
|
|
|
wfDeprecated( 'preprocessor=Preprocessor_DOM', '1.36' );
|
|
|
|
|
return false; // Skip test.
|
|
|
|
|
}
|
|
|
|
|
$teardownGuard = $this->perTestSetup( $test );
|
|
|
|
|
[ $title, $options, $revId ] = $this->setupParserOptions(
|
2022-05-20 20:42:25 +00:00
|
|
|
$test,
|
2022-08-27 21:28:14 +00:00
|
|
|
static function ( $context, $title, $revProps ) {
|
2020-07-24 04:41:09 +00:00
|
|
|
return ParserOptions::newFromContext( $context );
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2012-01-09 22:33:00 +00:00
|
|
|
$local = isset( $opts['local'] );
|
Remove Preprocessor_DOM, deprecated in 1.34
Remove the deprecated Preprocessor_DOM class, which was hard-deprecated
in 1.34. This begins to simplify parser configuration and reduce redundant
code paths, but I've left two things for cleanup in a future patch:
1. The `preprocessorClass` configuration option to the parser, exposed
in `$wgParserConf`, ServiceWiring, ParserFactory, etc. There is no reason
for this to be exposed as configurable, but I've left this clean up to a
future patch.
2. The `$wgMaxGeneratedPPNodeCount` configuration, exposed also in
ParserOptions. Only Preprocessor_DOM calculated this count, and since
we are only using Preprocessor_Hash now, this configuration has no effect.
But since this value was exposed in ParserOptions and elsewhere, I've
deprecated where needed but left this clean up to a future patch.
Bug: T204945
Change-Id: I727f003f9a42d0c92bcbcce8a8289d5af6cd1298
2020-01-24 21:23:46 +00:00
|
|
|
$parser = $this->getParser();
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2018-02-26 21:49:08 +00:00
|
|
|
if ( isset( $opts['styletag'] ) ) {
|
|
|
|
|
// For testing the behavior of <style> (including those deduplicated
|
|
|
|
|
// into <link> tags), add tag hooks to allow them to be generated.
|
2021-02-07 13:10:36 +00:00
|
|
|
$parser->setHook( 'style', static function ( $content, $attributes, $parser ) {
|
2018-02-26 21:49:08 +00:00
|
|
|
$marker = Parser::MARKER_PREFIX . '-style-' . md5( $content ) . Parser::MARKER_SUFFIX;
|
2022-06-01 21:19:57 +00:00
|
|
|
// @phan-suppress-next-line SecurityCheck-XSS
|
2021-02-19 22:01:19 +00:00
|
|
|
$parser->getStripState()->addNoWiki( $marker, $content );
|
2018-02-26 21:49:08 +00:00
|
|
|
return Html::inlineStyle( $marker, 'all', $attributes );
|
|
|
|
|
} );
|
2021-02-07 13:10:36 +00:00
|
|
|
$parser->setHook( 'link', static function ( $content, $attributes, $parser ) {
|
2018-02-26 21:49:08 +00:00
|
|
|
return Html::element( 'link', $attributes );
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
$wikitext = $test->wikitext;
|
|
|
|
|
'@phan-var string $wikitext'; // assert that this is not null
|
2012-01-09 22:33:00 +00:00
|
|
|
if ( isset( $opts['pst'] ) ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
$out = $parser->preSaveTransform( $wikitext, $title, $options->getUserIdentity(), $options );
|
2017-07-07 01:06:43 +00:00
|
|
|
$output = $parser->getOutput();
|
2012-01-09 22:33:00 +00:00
|
|
|
} elseif ( isset( $opts['msg'] ) ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
$out = $parser->transformMsg( $wikitext, $options, $title );
|
2012-01-09 22:33:00 +00:00
|
|
|
} elseif ( isset( $opts['section'] ) ) {
|
|
|
|
|
$section = $opts['section'];
|
2022-05-20 20:42:25 +00:00
|
|
|
$out = $parser->getSection( $wikitext, $section );
|
2012-01-09 22:33:00 +00:00
|
|
|
} elseif ( isset( $opts['replace'] ) ) {
|
|
|
|
|
$section = $opts['replace'][0];
|
|
|
|
|
$replace = $opts['replace'][1];
|
2022-05-20 20:42:25 +00:00
|
|
|
$out = $parser->replaceSection( $wikitext, $section, $replace );
|
2012-01-09 22:33:00 +00:00
|
|
|
} elseif ( isset( $opts['comment'] ) ) {
|
2022-12-11 00:33:56 +00:00
|
|
|
$out = MediaWikiServices::getInstance()->getCommentFormatter()->format( $wikitext, $title, $local );
|
2012-01-09 22:33:00 +00:00
|
|
|
} elseif ( isset( $opts['preload'] ) ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
$out = $parser->getPreloadText( $wikitext, $title, $options );
|
2012-01-09 22:33:00 +00:00
|
|
|
} else {
|
2022-05-20 20:42:25 +00:00
|
|
|
$output = $parser->parse( $wikitext, $title, $options, true, true, $revId );
|
2017-11-22 20:07:51 +00:00
|
|
|
$out = $output->getText( [
|
2017-12-22 18:32:49 +00:00
|
|
|
'allowTOC' => !isset( $opts['notoc'] ),
|
|
|
|
|
'unwrap' => !isset( $opts['wrap'] ),
|
2017-11-22 20:07:51 +00:00
|
|
|
] );
|
2020-04-01 21:24:13 +00:00
|
|
|
$out = preg_replace( '/\s+$/', '', $out );
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2022-01-24 01:28:24 +00:00
|
|
|
$this->addParserOutputInfo( $out, $output, $opts, $title );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
2017-07-07 01:06:43 +00:00
|
|
|
if ( isset( $output ) && isset( $opts['showflags'] ) ) {
|
2022-07-26 18:16:28 +00:00
|
|
|
$actualFlags = [];
|
|
|
|
|
foreach ( ParserOutputFlags::cases() as $name ) {
|
|
|
|
|
if ( $output->getOutputFlag( $name ) ) {
|
|
|
|
|
$actualFlags[] = $name;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-07 01:06:43 +00:00
|
|
|
sort( $actualFlags );
|
2018-02-17 12:29:13 +00:00
|
|
|
$out .= "\nflags=" . implode( ', ', $actualFlags );
|
2022-07-26 18:16:28 +00:00
|
|
|
# In 1.21 we deprecated the use of arbitrary keys for
|
|
|
|
|
# ParserOutput::setFlag() by extensions; if we find anyone
|
|
|
|
|
# still doing that complain about it.
|
|
|
|
|
$oldFlags = array_diff_key(
|
|
|
|
|
TestingAccessWrapper::newFromObject( $output )->mFlags,
|
|
|
|
|
array_fill_keys( ParserOutputFlags::cases(), true )
|
|
|
|
|
);
|
|
|
|
|
if ( $oldFlags ) {
|
|
|
|
|
wfDeprecated( 'Arbitrary flags in ParserOutput', '1.39' );
|
|
|
|
|
}
|
2017-07-07 01:06:43 +00:00
|
|
|
}
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
ScopedCallback::consume( $teardownGuard );
|
2013-03-19 14:00:44 +00:00
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
$expected = $test->legacyHtml;
|
|
|
|
|
'@phan-var string $expected'; // assert that this is not null
|
2016-03-09 04:42:33 +00:00
|
|
|
if ( count( $this->normalizationFunctions ) ) {
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$expected = ParserTestResultNormalizer::normalize(
|
2022-05-20 20:42:25 +00:00
|
|
|
$expected, $this->normalizationFunctions );
|
2016-03-09 04:42:33 +00:00
|
|
|
$out = ParserTestResultNormalizer::normalize( $out, $this->normalizationFunctions );
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
$testResult = new ParserTestResult( $test, $mode, $expected, $out );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
return $testResult;
|
2022-07-09 20:19:27 +00:00
|
|
|
}
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2022-01-24 01:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Add information from the parser output to the result string
|
|
|
|
|
*
|
|
|
|
|
* @param string &$out
|
|
|
|
|
* @param ParserOutput $output
|
|
|
|
|
* @param array $opts
|
|
|
|
|
* @param Title $title
|
|
|
|
|
*/
|
|
|
|
|
private function addParserOutputInfo( &$out, ParserOutput $output, array $opts, Title $title ) {
|
|
|
|
|
if ( isset( $opts['showtitle'] ) ) {
|
|
|
|
|
if ( $output->getTitleText() ) {
|
|
|
|
|
$titleText = $output->getTitleText();
|
|
|
|
|
} else {
|
|
|
|
|
$titleText = $title->getPrefixedText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$out = "$titleText\n$out";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $opts['showindicators'] ) ) {
|
|
|
|
|
$indicators = '';
|
|
|
|
|
foreach ( $output->getIndicators() as $id => $content ) {
|
|
|
|
|
$indicators .= "$id=$content\n";
|
|
|
|
|
}
|
|
|
|
|
$out = $indicators . $out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $opts['ill'] ) ) {
|
|
|
|
|
$out = implode( ' ', $output->getLanguageLinks() );
|
|
|
|
|
} elseif ( isset( $opts['cat'] ) ) {
|
|
|
|
|
$out = '';
|
|
|
|
|
foreach ( $output->getCategories() as $name => $sortkey ) {
|
|
|
|
|
if ( $out !== '' ) {
|
|
|
|
|
$out .= "\n";
|
|
|
|
|
}
|
|
|
|
|
$out .= "cat=$name sort=$sortkey";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $opts['extension'] ) ) {
|
|
|
|
|
foreach ( explode( ',', $opts['extension'] ) as $ext ) {
|
|
|
|
|
if ( $out !== '' ) {
|
|
|
|
|
$out .= "\n";
|
|
|
|
|
}
|
|
|
|
|
$out .= "extension[$ext]=" .
|
|
|
|
|
json_encode(
|
|
|
|
|
$output->getExtensionData( $ext ),
|
|
|
|
|
JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( isset( $opts['property'] ) ) {
|
|
|
|
|
foreach ( explode( ',', $opts['property'] ) as $prop ) {
|
|
|
|
|
if ( $out !== '' ) {
|
|
|
|
|
$out .= "\n";
|
|
|
|
|
}
|
|
|
|
|
$out .= "property[$prop]=" .
|
2022-02-16 22:03:26 +00:00
|
|
|
( $output->getPageProperty( $prop ) ?? '' );
|
2022-01-24 01:28:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
/**
|
|
|
|
|
* This processes test results and updates the known failures info for the test
|
|
|
|
|
*
|
|
|
|
|
* @param ParserTest $test
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTestMode $mode
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
* @param string|null|callable $rawExpected
|
2022-05-20 20:42:25 +00:00
|
|
|
* If null, indicates that the normalizer should look for the expected
|
|
|
|
|
* output in the $test object.
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
* @param string $rawActual
|
|
|
|
|
* @param callable $normalizer normalizer of expected & actual output strings
|
2022-07-19 01:04:31 +00:00
|
|
|
* @return ParserTestResult|false
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
*/
|
|
|
|
|
private function processResults(
|
2022-05-20 20:42:25 +00:00
|
|
|
ParserTest $test, ParserTestMode $mode, $rawExpected, string $rawActual, callable $normalizer
|
2022-07-19 01:04:31 +00:00
|
|
|
) {
|
|
|
|
|
if ( $mode->isCachingMode() ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-14 05:06:03 +00:00
|
|
|
if ( !$this->options['knownFailures'] ) {
|
|
|
|
|
$expectedFailure = null;
|
|
|
|
|
} else {
|
2022-05-20 20:42:25 +00:00
|
|
|
$expectedFailure = $test->knownFailures["$mode"] ?? null;
|
2022-05-14 05:06:03 +00:00
|
|
|
}
|
2022-07-27 18:18:17 +00:00
|
|
|
|
|
|
|
|
$expectedToFail = $expectedFailure !== null;
|
|
|
|
|
$knownFailureChanged = $expectedToFail && $expectedFailure !== $rawActual;
|
|
|
|
|
|
|
|
|
|
if ( is_callable( $rawExpected ) ) {
|
|
|
|
|
$rawExpected = $rawExpected();
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
}
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $actual, $expected ] = $normalizer( $rawActual, $rawExpected, false /* standalone */ );
|
2022-07-27 18:18:17 +00:00
|
|
|
$passed = $actual === $expected;
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
|
2022-07-27 18:18:17 +00:00
|
|
|
$unexpectedPass = $expectedToFail && $passed;
|
|
|
|
|
$unexpectedFail = !$expectedToFail && !$passed;
|
|
|
|
|
|
|
|
|
|
if ( $unexpectedPass ) {
|
|
|
|
|
$this->recorder->warning( "{$test->testName}: $mode: EXPECTED TO FAIL, BUT PASSED!" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $this->options['updateKnownFailures'] && (
|
|
|
|
|
$knownFailureChanged || $unexpectedFail || $unexpectedPass
|
|
|
|
|
) ) {
|
|
|
|
|
if ( $unexpectedPass ) {
|
|
|
|
|
unset( $test->knownFailures["$mode"] );
|
2022-07-19 01:04:31 +00:00
|
|
|
} else {
|
2022-07-27 18:18:17 +00:00
|
|
|
if ( $knownFailureChanged ) {
|
|
|
|
|
$this->recorder->warning( "{$test->testName}: $mode: KNOWN FAILURE CHANGED!" );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
}
|
2022-07-27 18:18:17 +00:00
|
|
|
$test->knownFailures["$mode"] = $rawActual;
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-27 18:18:17 +00:00
|
|
|
if ( $unexpectedPass ) {
|
|
|
|
|
if ( !$this->options['updateKnownFailures'] ) {
|
|
|
|
|
$this->unexpectedTestPasses = true;
|
|
|
|
|
}
|
|
|
|
|
} elseif ( $expectedToFail && !$knownFailureChanged ) {
|
|
|
|
|
// Don't flag failures noisily when nothing really changed
|
|
|
|
|
$expected = $expectedFailure;
|
|
|
|
|
$actual = $rawActual;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
return new ParserTestResult( $test, $mode, $expected, $actual );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function fetchCachedDoc( $parsoid, $pageConfig, $test ) {
|
|
|
|
|
// If cachedBODYstr is not already set, create it here.
|
|
|
|
|
if ( $test->cachedBODYstr === null ) {
|
|
|
|
|
$this->wt2html( $parsoid, $pageConfig, $test, new ParserTestMode( 'cache' ) );
|
|
|
|
|
}
|
|
|
|
|
$doc = DOMUtils::parseHTML( $test->cachedBODYstr, true );
|
|
|
|
|
// XXX applyChanges calls functions in WTUtils which assume we
|
|
|
|
|
// have a DataBag associated with the document.
|
|
|
|
|
DOMDataUtils::prepareDoc( $doc );
|
|
|
|
|
return $doc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function fetchCachedWt( $parsoid, $pageConfig, $test ) {
|
|
|
|
|
// If cachedWTstr is not already set, set it here.
|
|
|
|
|
if ( ( $test->cachedWTstr ?? null ) === null ) {
|
|
|
|
|
$this->html2wt( $parsoid, $pageConfig, $test, new ParserTestMode( 'cache' ) );
|
|
|
|
|
}
|
|
|
|
|
return $test->cachedWTstr;
|
2022-04-02 06:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-14 18:36:57 +00:00
|
|
|
/**
|
|
|
|
|
* Run wt2html on the test
|
2020-07-24 04:41:09 +00:00
|
|
|
*
|
2022-03-14 18:36:57 +00:00
|
|
|
* @param Parsoid $parsoid
|
|
|
|
|
* @param PageConfig $pageConfig
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
* @param ParserTest $test
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTestMode $mode
|
2020-07-24 04:41:09 +00:00
|
|
|
* @return ParserTestResult|false false if skipped
|
|
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
private function wt2html( Parsoid $parsoid, PageConfig $pageConfig, ParserTest $test, ParserTestMode $mode ) {
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$html = $test->sections['html/parsoid+integrated'] ?? $test->parsoidHtml;
|
2022-05-20 20:42:25 +00:00
|
|
|
Assert::invariant(
|
|
|
|
|
$test->wikitext !== null,
|
|
|
|
|
"All tests include a wikitext section"
|
|
|
|
|
);
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
|
2022-07-19 01:04:31 +00:00
|
|
|
if ( $html === null && !$mode->isCachingMode() ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
// Nothing to test, but if mode is 'cache' we're executing this
|
|
|
|
|
// in order to set cachedBODYstr (say, for a wt2wt test)
|
|
|
|
|
return false;
|
2020-07-24 04:41:09 +00:00
|
|
|
}
|
2022-03-14 18:36:57 +00:00
|
|
|
|
|
|
|
|
$origOut = $parsoid->wikitext2html( $pageConfig, [
|
|
|
|
|
'body_only' => true,
|
2022-04-02 06:27:47 +00:00
|
|
|
'wrapSections' => $test->options['parsoid']['wrapSections'] ?? false,
|
2022-03-14 18:36:57 +00:00
|
|
|
] );
|
|
|
|
|
$test->cachedBODYstr = $origOut;
|
|
|
|
|
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
return $this->processResults(
|
2022-05-20 20:42:25 +00:00
|
|
|
// Passing 'null' for expected output here asks normalizeHTML
|
|
|
|
|
// to look it up for us, based on parsoid-only & standalone status
|
|
|
|
|
$test, $mode, null, $origOut, [ $test, "normalizeHTML" ]
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
);
|
2022-03-14 18:36:57 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-15 11:15:18 +00:00
|
|
|
/**
|
|
|
|
|
* @param Parsoid $parsoid
|
|
|
|
|
* @param PageConfig $pageConfig
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
* @param ParserTest $test
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTestMode $mode
|
2022-03-15 11:15:18 +00:00
|
|
|
* @return ParserTestResult|false false if skipped
|
|
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
private function wt2wt( Parsoid $parsoid, PageConfig $pageConfig, ParserTest $test, ParserTestMode $mode ) {
|
2022-07-18 23:54:45 +00:00
|
|
|
$html = $test->sections['html/parsoid+integrated'] ?? $test->parsoidHtml;
|
|
|
|
|
if ( $html === null ) {
|
|
|
|
|
// We currently don't run this in standalone mode.
|
|
|
|
|
// The expectation is to add html/parsoid sections
|
|
|
|
|
// if we want to run these tests.
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
Assert::invariant(
|
|
|
|
|
$test->wikitext !== null,
|
|
|
|
|
"All tests include a wikitext section"
|
|
|
|
|
);
|
2022-03-15 11:15:18 +00:00
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
// Handle a 'changes' option if present.
|
|
|
|
|
$doc = $this->fetchCachedDoc( $parsoid, $pageConfig, $test );
|
|
|
|
|
$testManualChanges = $test->options['parsoid']['changes'] ?? null;
|
|
|
|
|
if ( $testManualChanges ) {
|
|
|
|
|
$test->applyManualChanges( $doc );
|
2022-03-15 11:15:18 +00:00
|
|
|
}
|
|
|
|
|
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$origWT = $parsoid->dom2wikitext( $pageConfig, $doc );
|
|
|
|
|
if ( isset( $test->options['parsoid']['changes'] ) ) {
|
|
|
|
|
$expectedWT = $test->sections['wikitext/edited'];
|
|
|
|
|
} else {
|
|
|
|
|
$expectedWT = $test->wikitext;
|
2022-03-15 11:15:18 +00:00
|
|
|
}
|
|
|
|
|
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
return $this->processResults(
|
2022-05-20 20:42:25 +00:00
|
|
|
$test, $mode, $expectedWT, $origWT, [ $test, "normalizeWT" ]
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
);
|
2022-04-02 06:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param Parsoid $parsoid
|
|
|
|
|
* @param PageConfig $pageConfig
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
* @param ParserTest $test
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTestMode $mode
|
2022-04-02 06:27:47 +00:00
|
|
|
* @return ParserTestResult|false false if skipped
|
|
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
private function html2wt( Parsoid $parsoid, PageConfig $pageConfig, ParserTest $test, ParserTestMode $mode ) {
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$html = $test->sections['html/parsoid+integrated'] ?? $test->parsoidHtml;
|
|
|
|
|
if ( $html === null ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
// Although ::getTestSkipMessage checks that parsoid-only tests
|
|
|
|
|
// have html sections, this test would have (eg) only an
|
|
|
|
|
// html/parsoid+standalone section, and we're executing in
|
|
|
|
|
// integrated mode.
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
return false; // Skip. Nothing to test.
|
|
|
|
|
}
|
2022-07-19 01:04:31 +00:00
|
|
|
if ( $test->wikitext === null && !$mode->isCachingMode() ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
// If mode is 'cache' we're executing this in order to
|
|
|
|
|
// set cachedWTstr.
|
|
|
|
|
throw new MWException( 'Error in the test setup' );
|
2022-04-02 06:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
$test->cachedWTstr = $origWT = $parsoid->html2wikitext( $pageConfig, $html );
|
2022-04-02 06:27:47 +00:00
|
|
|
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
return $this->processResults(
|
2022-05-20 20:42:25 +00:00
|
|
|
$test, $mode, $test->wikitext ?? '', $origWT, [ $test, "normalizeWT" ]
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
);
|
2022-04-02 06:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param Parsoid $parsoid
|
|
|
|
|
* @param PageConfig $pageConfig
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
* @param ParserTest $test
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTestMode $mode
|
2022-04-02 06:27:47 +00:00
|
|
|
* @return ParserTestResult|false false if skipped
|
|
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
private function html2html( Parsoid $parsoid, PageConfig $pageConfig, ParserTest $test, ParserTestMode $mode ) {
|
2022-04-02 06:27:47 +00:00
|
|
|
$html = $test->sections['html/parsoid+integrated'] ?? $test->parsoidHtml;
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
if ( $html === null ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
// Although ::getTestSkipMessage checks that parsoid-only tests
|
|
|
|
|
// have html sections, this test would have (eg) only an
|
|
|
|
|
// html/parsoid+standalone section, and we're executing in
|
|
|
|
|
// integrated mode.
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
return false; // Skip. Nothing to test.
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
$wt = $this->fetchCachedWt( $parsoid, $pageConfig, $test );
|
2022-04-02 06:27:47 +00:00
|
|
|
|
|
|
|
|
// Construct a fresh PageConfig object with $wt
|
|
|
|
|
$oldWt = $test->wikitext;
|
|
|
|
|
$test->wikitext = $wt;
|
2022-09-26 22:13:37 +00:00
|
|
|
$pageConfig = $this->setupParserOptionsAndBuildPageConfig( $test );
|
2022-04-02 06:27:47 +00:00
|
|
|
$test->wikitext = $oldWt;
|
|
|
|
|
|
|
|
|
|
$newHtml = $parsoid->wikitext2html( $pageConfig, [
|
|
|
|
|
'body_only' => true,
|
|
|
|
|
'wrapSections' => $test->options['parsoid']['wrapSections'] ?? false,
|
|
|
|
|
] );
|
|
|
|
|
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
return $this->processResults(
|
2022-05-20 20:42:25 +00:00
|
|
|
$test, $mode, $test->cachedNormalizedHTML, $newHtml, [ $test, "normalizeHTML" ]
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
);
|
2022-04-02 06:27:47 +00:00
|
|
|
}
|
|
|
|
|
|
2022-04-04 10:44:11 +00:00
|
|
|
/**
|
|
|
|
|
* @param Parsoid $parsoid
|
|
|
|
|
* @param PageConfig $pageConfig
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
* @param ParserTest $test
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTestMode $mode
|
2022-04-04 10:44:11 +00:00
|
|
|
* @return ParserTestResult|false false if skipped
|
|
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
private function selser( Parsoid $parsoid, PageConfig $pageConfig, ParserTest $test, ParserTestMode $mode ) {
|
2022-07-18 23:54:45 +00:00
|
|
|
$html = $test->sections['html/parsoid+integrated'] ?? $test->parsoidHtml;
|
|
|
|
|
if ( $html === null ) {
|
|
|
|
|
// We currently don't run this in standalone mode.
|
|
|
|
|
// The expectation is to add html/parsoid sections
|
|
|
|
|
// if we want to run these tests.
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
Assert::invariant(
|
|
|
|
|
$test->wikitext !== null,
|
|
|
|
|
"All tests include a wikitext section"
|
|
|
|
|
);
|
2022-04-04 10:44:11 +00:00
|
|
|
|
2022-06-01 21:19:57 +00:00
|
|
|
if ( $test->changetree === [ 'manual' ] && !isset( $test->options['parsoid']['changes'] ) ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
throw new MWException( 'Error in the test setup!' );
|
2022-04-04 10:44:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Apply edits to the HTML.
|
|
|
|
|
// Always serialize to string and reparse before passing to selser/wt2wt.
|
2022-05-20 20:42:25 +00:00
|
|
|
$doc = $this->fetchCachedDoc( $parsoid, $pageConfig, $test );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
if ( $test->changetree === [ 'manual' ] ) {
|
2022-04-04 10:44:11 +00:00
|
|
|
$test->applyManualChanges( $doc );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$expectedWT = $test->sections['wikitext/edited'];
|
2022-05-20 20:42:25 +00:00
|
|
|
$expectedFailure = $test->knownFailures["$mode"] ?? null;
|
2022-04-04 10:44:11 +00:00
|
|
|
} else {
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
// $test->changetree === [ 5 ]
|
2022-05-20 20:42:25 +00:00
|
|
|
$changetree = $test->changetree;
|
|
|
|
|
'@phan-var array $changetree'; // assert that this is not null
|
|
|
|
|
$test->applyChanges( [], $doc, $changetree );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$expectedWT = $test->wikitext;
|
2022-05-20 20:42:25 +00:00
|
|
|
$expectedFailure = $test->knownFailures["$mode"] ?? null;
|
2022-04-04 10:44:11 +00:00
|
|
|
}
|
|
|
|
|
$editedHTML = ContentUtils::toXML( DOMCompat::getBody( $doc ) );
|
|
|
|
|
|
|
|
|
|
// Run selser on edited doc
|
|
|
|
|
$selserData = new SelserData( $test->wikitext, $test->cachedBODYstr );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$origWT = $parsoid->html2wikitext( $pageConfig, $editedHTML, [], $selserData );
|
2022-04-04 10:44:11 +00:00
|
|
|
|
|
|
|
|
if ( $test->changetree === [ 5 ] ) {
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$origWT = preg_replace( '/<!--' . ParserTest::STATIC_RANDOM_STRING . '-->/', '', $origWT );
|
2022-04-04 10:44:11 +00:00
|
|
|
}
|
|
|
|
|
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
return $this->processResults(
|
2022-05-20 20:42:25 +00:00
|
|
|
$test, $mode, $expectedWT, $origWT, [ $test, "normalizeWT" ]
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param Parsoid $parsoid
|
|
|
|
|
* @param PageConfig $pageConfig
|
|
|
|
|
* @param ParserTest $test
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTestMode $mode
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
* @param Document $doc
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
private function runSelserEditTest(
|
2022-05-20 20:42:25 +00:00
|
|
|
Parsoid $parsoid, PageConfig $pageConfig, ParserTest $test, ParserTestMode $mode, Document $doc
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
): array {
|
|
|
|
|
$test->applyChanges( [], $doc, $test->changetree );
|
|
|
|
|
$editedHTML = ContentUtils::toXML( DOMCompat::getBody( $doc ) );
|
|
|
|
|
|
|
|
|
|
// Run selser on edited doc
|
|
|
|
|
$selserData = new SelserData( $test->wikitext, $test->cachedBODYstr );
|
|
|
|
|
$origWT = $parsoid->html2wikitext( $pageConfig, $editedHTML, [], $selserData );
|
|
|
|
|
|
|
|
|
|
$ptResult = $this->processResults(
|
2022-05-20 20:42:25 +00:00
|
|
|
$test, $mode,
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
static function () use ( $parsoid, $pageConfig, $editedHTML ): string {
|
|
|
|
|
return $parsoid->html2wikitext( $pageConfig, $editedHTML );
|
|
|
|
|
},
|
|
|
|
|
$origWT, [ $test, "normalizeWT" ]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return [ $ptResult->actual, $ptResult->expected ];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param Parsoid $parsoid
|
|
|
|
|
* @param PageConfig $pageConfig
|
|
|
|
|
* @param ParserTest $test
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTestMode $mode
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
* @return ParserTestResult|false false if skipped
|
|
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
private function selserAutoEdit( Parsoid $parsoid, PageConfig $pageConfig, ParserTest $test, ParserTestMode $mode ) {
|
2022-07-18 23:54:45 +00:00
|
|
|
$html = $test->sections['html/parsoid+integrated'] ?? $test->parsoidHtml;
|
|
|
|
|
if ( $html === null ) {
|
|
|
|
|
// We currently don't run this in standalone mode.
|
|
|
|
|
// The expectation is to add html/parsoid sections
|
|
|
|
|
// if we want to run these tests.
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-05-20 20:42:25 +00:00
|
|
|
Assert::invariant(
|
|
|
|
|
$test->wikitext !== null,
|
|
|
|
|
"All tests include a wikitext section"
|
|
|
|
|
);
|
2022-05-14 05:06:03 +00:00
|
|
|
|
|
|
|
|
// Apply edits to the HTML.
|
|
|
|
|
// Always serialize to string and reparse before passing to selser/wt2wt.
|
2022-05-20 20:42:25 +00:00
|
|
|
$doc = $this->fetchCachedDoc( $parsoid, $pageConfig, $test );
|
2022-05-14 05:06:03 +00:00
|
|
|
if ( !$test->changetree ) {
|
|
|
|
|
$test->changetree = $test->generateChanges( $doc );
|
|
|
|
|
if ( !$test->changetree ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
// No more changes to make
|
2022-05-14 05:06:03 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2022-05-20 20:42:25 +00:00
|
|
|
$mode = new ParserTestMode( 'selser', $test->changetree );
|
2022-05-14 05:06:03 +00:00
|
|
|
}
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $out, $expected ] = $this->runSelserEditTest( $parsoid, $pageConfig, $test, $mode, $doc );
|
2022-05-14 05:06:03 +00:00
|
|
|
return new ParserTestResult(
|
2022-05-20 20:42:25 +00:00
|
|
|
$test,
|
|
|
|
|
$mode,
|
2022-05-14 05:06:03 +00:00
|
|
|
$expected,
|
|
|
|
|
$out
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param Parsoid $parsoid
|
|
|
|
|
* @param PageConfig $pageConfig
|
|
|
|
|
* @param ParserTest $test
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTestMode $mode
|
2022-05-14 05:06:03 +00:00
|
|
|
* @return ParserTestResult|false false if skipped
|
|
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
private function selserAutoEditComposite( Parsoid $parsoid, PageConfig $pageConfig, ParserTest $test, ParserTestMode $mode ) {
|
|
|
|
|
Assert::invariant(
|
|
|
|
|
$test->wikitext !== null,
|
|
|
|
|
"All tests include a wikitext section"
|
|
|
|
|
);
|
|
|
|
|
$runnerOpts = $this->getOptions();
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
|
|
|
|
|
if ( $test->changetree ) {
|
|
|
|
|
// Apply edits to the HTML.
|
|
|
|
|
// Always serialize to string and reparse before passing to selser/wt2wt.
|
2022-05-20 20:42:25 +00:00
|
|
|
$doc = $this->fetchCachedDoc( $parsoid, $pageConfig, $test );
|
|
|
|
|
Assert::invariant(
|
|
|
|
|
$mode->changetree === $test->changetree,
|
|
|
|
|
"changetree should be consistent with mode"
|
|
|
|
|
);
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $out, $expected ] = $this->runSelserEditTest( $parsoid, $pageConfig, $test, $mode, $doc );
|
2022-05-20 20:42:25 +00:00
|
|
|
return new ParserTestResult( $test, $mode, $expected, $out );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
} else {
|
2022-05-20 20:42:25 +00:00
|
|
|
// this mode is a composite of multiple selser tests
|
|
|
|
|
$mode = new ParserTestMode( "selserAutoEdits" );
|
|
|
|
|
$numChanges = $runnerOpts['numchanges'] ?? 20; // default in Parsoid
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$results = [];
|
|
|
|
|
$bufOut = "";
|
|
|
|
|
$bufExpected = "";
|
|
|
|
|
for ( $i = 0; $i < $numChanges; $i++ ) {
|
|
|
|
|
// Apply edits to the HTML.
|
|
|
|
|
// Always serialize to string and reparse before passing to selser/wt2wt.
|
2022-05-20 20:42:25 +00:00
|
|
|
$doc = $this->fetchCachedDoc( $parsoid, $pageConfig, $test );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$test->seed = $i . '';
|
|
|
|
|
$test->changetree = $test->generateChanges( $doc );
|
|
|
|
|
if ( $test->changetree ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
// new mode with the generated changetree
|
|
|
|
|
$nmode = new ParserTestMode( 'selser', $test->changetree );
|
2022-10-21 04:32:38 +00:00
|
|
|
[ $out, $expected ] = $this->runSelserEditTest( $parsoid, $pageConfig, $test, $nmode, $doc );
|
2022-05-20 20:42:25 +00:00
|
|
|
$testTitle = "TEST: {$test->testName} ($nmode)\n";
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$bufOut .= $testTitle;
|
|
|
|
|
$bufExpected .= $testTitle;
|
|
|
|
|
$bufOut .= "RESULT: $out\n";
|
|
|
|
|
$bufExpected .= "RESULT: $expected\n";
|
|
|
|
|
}
|
|
|
|
|
// $test->changetree can be [] which is a NOP for testing
|
|
|
|
|
// but not a NOP for duplicate change tree tests.
|
|
|
|
|
if ( $test->isDuplicateChangeTree( $test->changetree ) ) {
|
|
|
|
|
// Once we get a duplicate change tree, we can no longer
|
|
|
|
|
// generate and run new tests. So, be done now!
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
$test->selserChangeTrees[$i] = $test->changetree;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-20 20:42:25 +00:00
|
|
|
return new ParserTestResult( $test, $mode, $bufExpected, $bufOut );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
}
|
2022-04-04 10:44:11 +00:00
|
|
|
}
|
|
|
|
|
|
2022-09-26 22:13:37 +00:00
|
|
|
private function setupParserOptionsAndBuildPageConfig( ParserTest $test ): PageConfig {
|
2022-04-21 10:54:28 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
$pageConfigFactory = $services->get( 'ParsoidPageConfigFactory' );
|
|
|
|
|
$pageConfig = null;
|
|
|
|
|
$runner = $this;
|
|
|
|
|
[ $title, $options, $revId ] = $this->setupParserOptions(
|
|
|
|
|
$test,
|
2022-08-27 21:28:14 +00:00
|
|
|
static function ( $context, $title, $revProps ) use ( $runner, $pageConfigFactory, &$pageConfig ) {
|
2022-04-21 10:54:28 +00:00
|
|
|
$user = $context->getUser();
|
2022-08-27 21:28:14 +00:00
|
|
|
$revRecord = $revProps['rev'] ?? null;
|
|
|
|
|
if ( !$revRecord ) {
|
|
|
|
|
// Unlike the legacy parser which doesn't need an actual revrecord to parse
|
|
|
|
|
// wikitext, Parsoid creates a PageConfig which needs an actual revrecord.
|
|
|
|
|
// So create a fake mutable on here.
|
|
|
|
|
$revRecord = $runner->createRevRecord( $title, $user, $revProps );
|
|
|
|
|
}
|
2022-04-21 10:54:28 +00:00
|
|
|
$pageConfig = $pageConfigFactory->create(
|
2022-06-17 19:54:45 +00:00
|
|
|
$title, $user, $revRecord, null, $context->getLanguage()->getCode()
|
2022-04-21 10:54:28 +00:00
|
|
|
);
|
|
|
|
|
return $pageConfig->getParserOptions();
|
|
|
|
|
} );
|
2022-09-26 22:13:37 +00:00
|
|
|
'@phan-var PageConfig $pageConfig'; // assert that this is not null
|
|
|
|
|
return $pageConfig;
|
2022-04-21 10:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
/**
|
|
|
|
|
* Helper function to register a Parsoid extension module in such a
|
|
|
|
|
* way that it can be cleaned up after the test is complete.
|
|
|
|
|
* @param SiteConfig $siteConfig
|
|
|
|
|
* @param class-string<ExtensionModule> $moduleName
|
|
|
|
|
* @return callable
|
|
|
|
|
*/
|
|
|
|
|
private static function registerExtensionModule( SiteConfig $siteConfig, string $moduleName ): callable {
|
|
|
|
|
$id = $siteConfig->registerExtensionModule( $moduleName );
|
|
|
|
|
return static function () use ( $siteConfig, $id ) {
|
|
|
|
|
$siteConfig->unregisterExtensionModule( $id );
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 18:36:57 +00:00
|
|
|
/**
|
|
|
|
|
* Run a given wikitext input through a freshly-constructed Parsoid parser,
|
|
|
|
|
* running in 'integrated' mode, and compare the output against the
|
|
|
|
|
* expected results.
|
|
|
|
|
*
|
|
|
|
|
* Prints status and explanatory messages to stdout.
|
|
|
|
|
*
|
|
|
|
|
* staticSetup() and setupWikiData() must be called before this function
|
|
|
|
|
* is entered.
|
|
|
|
|
*
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
* @param ParserTest $test The test parameters:
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTestMode $mode Parsoid test mode to run (including specific
|
|
|
|
|
* changetree to run selser test in, if applicable)
|
2022-03-14 18:36:57 +00:00
|
|
|
*
|
|
|
|
|
* @return ParserTestResult|false false if skipped
|
|
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
public function runParsoidTest( ParserTest $test, ParserTestMode $mode ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": running {$test->testName} [$mode]" );
|
2022-03-15 11:15:18 +00:00
|
|
|
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
// Skip deprecated preprocessor tests
|
2022-06-01 21:19:57 +00:00
|
|
|
// @phan-suppress-next-line PhanImpossibleCondition Other preprocessor are deprecated, see runTest
|
2022-03-15 11:15:18 +00:00
|
|
|
if ( isset( $opts['preprocessor'] ) && $opts['preprocessor'] !== 'Preprocessor_Hash' ) {
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
return false;
|
2022-03-15 11:15:18 +00:00
|
|
|
}
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
|
2022-03-15 11:15:18 +00:00
|
|
|
// Skip tests targetting features Parsoid doesn't (yet) support
|
|
|
|
|
// @todo T270312
|
|
|
|
|
if ( isset( $opts['styletag'] ) || isset( $opts['pst'] ) ||
|
|
|
|
|
isset( $opts['msg'] ) || isset( $opts['section'] ) ||
|
|
|
|
|
isset( $opts['replace'] ) || isset( $opts['comment'] ) ||
|
|
|
|
|
isset( $opts['preload'] ) || isset( $opts['showtitle'] ) ||
|
|
|
|
|
isset( $opts['showindicators'] ) || isset( $opts['ill'] ) ||
|
|
|
|
|
isset( $opts['cat'] ) || isset( $opts['showflags'] )
|
|
|
|
|
) {
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
return false;
|
2022-03-15 11:15:18 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
$teardownGuard = $this->perTestSetup( $test );
|
2022-09-26 22:13:37 +00:00
|
|
|
$pageConfig = $this->setupParserOptionsAndBuildPageConfig( $test );
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
$teardown = [];
|
2020-07-24 04:41:09 +00:00
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
// Register any special extensions required by this test case
|
|
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
$siteConfig = $services->get( 'ParsoidSiteConfig' );
|
|
|
|
|
$teardown[] = self::registerExtensionModule( $siteConfig, ParsoidParserHook::class );
|
|
|
|
|
if ( ( $test->options['wgrawhtml'] ?? null ) === '1' ) {
|
|
|
|
|
$teardown[] = self::registerExtensionModule( $siteConfig, ParsoidRawHTML::class );
|
2022-03-15 11:15:18 +00:00
|
|
|
}
|
2022-05-20 20:42:25 +00:00
|
|
|
if ( isset( $test->options['styletag'] ) ) {
|
|
|
|
|
$teardown[] = self::registerExtensionModule( $siteConfig, ParsoidStyleTag::class );
|
|
|
|
|
}
|
|
|
|
|
// unregister these after this test
|
|
|
|
|
$teardownGuard = $this->createTeardownObject( $teardown, $teardownGuard );
|
|
|
|
|
|
|
|
|
|
// Create the Parsoid object. (This is cheap, since the SiteConfig
|
|
|
|
|
// and DataAccess are cached by the ServiceContainer.)
|
|
|
|
|
$dataAccess = $services->get( 'ParsoidDataAccess' );
|
|
|
|
|
$parsoid = new Parsoid( $siteConfig, $dataAccess );
|
|
|
|
|
switch ( $mode->mode ) {
|
2022-04-02 06:27:47 +00:00
|
|
|
case 'wt2html':
|
|
|
|
|
case 'wt2html+integrated':
|
2022-05-20 20:42:25 +00:00
|
|
|
$res = $this->wt2html( $parsoid, $pageConfig, $test, $mode );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
break;
|
2022-04-02 06:27:47 +00:00
|
|
|
|
|
|
|
|
case 'wt2wt':
|
2022-05-20 20:42:25 +00:00
|
|
|
$res = $this->wt2wt( $parsoid, $pageConfig, $test, $mode );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
break;
|
2022-04-02 06:27:47 +00:00
|
|
|
|
|
|
|
|
case 'html2wt':
|
2022-05-20 20:42:25 +00:00
|
|
|
$res = $this->html2wt( $parsoid, $pageConfig, $test, $mode );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
break;
|
2022-04-02 06:27:47 +00:00
|
|
|
|
|
|
|
|
case 'html2html':
|
2022-05-20 20:42:25 +00:00
|
|
|
$res = $this->html2html( $parsoid, $pageConfig, $test, $mode );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
break;
|
2022-04-02 06:27:47 +00:00
|
|
|
|
2022-04-04 10:44:11 +00:00
|
|
|
case 'selser':
|
2022-05-20 20:42:25 +00:00
|
|
|
$test->changetree = $mode->changetree;
|
|
|
|
|
$res = $this->selser( $parsoid, $pageConfig, $test, $mode );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$test->changetree = null; // Reset after each selser test
|
|
|
|
|
break;
|
|
|
|
|
|
2022-05-14 05:06:03 +00:00
|
|
|
case 'selser-auto-composite':
|
2022-05-20 20:42:25 +00:00
|
|
|
$test->changetree = $mode->changetree;
|
|
|
|
|
$res = $this->selserAutoEditComposite( $parsoid, $pageConfig, $test, $mode );
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$test->changetree = null; // Reset after each selser test
|
|
|
|
|
break;
|
2022-04-04 10:44:11 +00:00
|
|
|
|
2022-05-14 05:06:03 +00:00
|
|
|
case 'selser-auto':
|
2022-05-20 20:42:25 +00:00
|
|
|
$test->changetree = $mode->changetree;
|
|
|
|
|
$res = $this->selserAutoEdit( $parsoid, $pageConfig, $test, $mode );
|
2022-05-14 05:06:03 +00:00
|
|
|
// Don't reset changetree here -- it is used to detect duplicate trees
|
|
|
|
|
// and stop selser test generation in Test.php::testAllModes
|
|
|
|
|
break;
|
|
|
|
|
|
2022-04-02 06:27:47 +00:00
|
|
|
default:
|
|
|
|
|
// Unsupported Mode
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
$res = false;
|
|
|
|
|
break;
|
2020-07-24 04:41:09 +00:00
|
|
|
}
|
ParserTest runner improvements (improve feature parity with Parsoid)
This patch improves the parser test runner in the following ways:
1. Adds Parsoid selser auto-edit test support
Since it isn't possible to dynamically add tests in PHPUnit
(unlike the home-grown parser test runners), to support selser
auto-edit tests, we create a single composite test that includes
all the individual edits. If a single test fails, the whole test
is considering failing.
The test output from all the individual tests are combined into
composite expected / actual strings and test failure diffs reveals
diffs for individual tests.
Future patches could enhance output further.
2. Ensure that we skip HTML-based Parsoid test modes without appropriate
input HTML
3. Pass additional options to the parser test runner via the
ParserTestTopLevelSuite constructor. These support extended
functionality of the Parsoid parser test runner which are being
made available to core.
At the moment the constructor will attempt to JSON-decode the
PARSERTEST_FLAGS environment variable to supply defaults for
these flags, which provides a hacky sort of way to pass arguments
on the command line. This will be integrated with the existing
$flags passed to ParserTestTopLevelSuite in the future (T308367).
4. Add support for running tests in specific modes as well
as ability to update the known failures json file.
This includes some missing code to run per-test teardown functions
in runParsoidTest.
Unlike the Parsoid parser test runner, you can combine
updateKnownFailures with --filter as well as with subset of
test modes, including possibly specific selser changetrees.
If `{"updateKnownFailures": true}` is set in the PARSERTEST_FLAGS var,
you can also update the knownFailures result for only the tests
that are run.
However, note that this could change the sort order in the
*-knownFailures.json file. This leads to dirty (git) diffs when
a full updateKnownFailures is run on the file. I am not going to
tackle this issue for now since this is an obscure use case that
is unlikely to be used much, if at all.
Overall, if I copy over the -knownFailures.json file from the Parsoid
repo into the Cite repo and update it with a phpunit.php run in core,
it updates the known failures to reflect changes to test results from
an integrated test run. A second run doesn't lead to any additional
changes to the knownFailures.json file or to any test failures. I had
to fix some bugs (referenced in the previous paragraph) to ensure
this idempotence beyond the first run.
This patch also cleans up some function signatures to use Test object
It maps the Test object from the Parsoid repo to an associative array
that a bunch of (legacy) parser test functions expect.
This patch squashes the following previous patches:
I2f46b4b94b44aec76e33403455eb466899376a6b
Ib01991089ec410dd45f77a20b136c8e05d855fa4
Id0ef01e333580892aa6d415b8f66c4393b06870d
Change-Id: I9952ab5ee3edef8e2f00b0e65cbffc42f46c2ea7
2022-04-06 09:36:37 +00:00
|
|
|
|
|
|
|
|
ScopedCallback::consume( $teardownGuard );
|
|
|
|
|
return $res;
|
2020-07-24 04:41:09 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-09 22:33:00 +00:00
|
|
|
/**
|
|
|
|
|
* Use a regex to find out the value of an option
|
2014-04-17 18:43:42 +00:00
|
|
|
* @param string $key Name of option val to retrieve
|
|
|
|
|
* @param array $opts Options array to look in
|
|
|
|
|
* @param mixed $default Default value returned if not found
|
2014-08-25 16:50:35 +00:00
|
|
|
* @return mixed
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
|
|
|
|
private static function getOptionValue( $key, $opts, $default ) {
|
|
|
|
|
$key = strtolower( $key );
|
2019-03-24 21:40:49 +00:00
|
|
|
return $opts[$key] ?? $default;
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* Do any required setup which is dependent on test options.
|
|
|
|
|
*
|
|
|
|
|
* @see staticSetup() for more information about setup/teardown
|
|
|
|
|
*
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTest $test Test info supplied by TestFileReader
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* @param callable|null $nextTeardown
|
|
|
|
|
* @return ScopedCallback
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
2022-05-20 20:42:25 +00:00
|
|
|
public function perTestSetup( ParserTest $test, $nextTeardown = null ) {
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$teardown = [];
|
|
|
|
|
|
2020-12-23 18:52:12 +00:00
|
|
|
$this->checkSetupDone( 'setupDatabase' );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$teardown[] = $this->markSetupDone( 'perTestSetup' );
|
|
|
|
|
|
2022-05-20 20:42:25 +00:00
|
|
|
$opts = $test->options;
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
|
|
|
|
|
// Find out values for some special options.
|
|
|
|
|
$langCode =
|
2012-01-09 22:33:00 +00:00
|
|
|
self::getOptionValue( 'language', $opts, 'en' );
|
|
|
|
|
$variant =
|
|
|
|
|
self::getOptionValue( 'variant', $opts, false );
|
|
|
|
|
$maxtoclevel =
|
|
|
|
|
self::getOptionValue( 'wgMaxTocLevel', $opts, 999 );
|
|
|
|
|
$linkHolderBatchSize =
|
|
|
|
|
self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
|
|
|
|
|
|
2017-07-20 01:42:56 +00:00
|
|
|
// Default to fallback skin, but allow it to be overridden
|
|
|
|
|
$skin = self::getOptionValue( 'skin', $opts, 'fallback' );
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$setup = [
|
2012-01-09 22:33:00 +00:00
|
|
|
'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
'wgLanguageCode' => $langCode,
|
2013-07-10 22:10:14 +00:00
|
|
|
'wgRawHtml' => self::getOptionValue( 'wgRawHtml', $opts, false ),
|
2017-02-23 21:14:54 +00:00
|
|
|
'wgNamespacesWithSubpages' => array_fill_keys(
|
2018-08-05 17:58:51 +00:00
|
|
|
MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces(),
|
|
|
|
|
isset( $opts['subpage'] )
|
2017-02-23 21:14:54 +00:00
|
|
|
),
|
2012-01-09 22:33:00 +00:00
|
|
|
'wgMaxTocLevel' => $maxtoclevel,
|
2013-07-10 22:10:14 +00:00
|
|
|
'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ),
|
2022-04-13 09:19:47 +00:00
|
|
|
'wgThumbLimits' => [ 0, 0, 0, 0, 0, self::getOptionValue( 'thumbsize', $opts, 180 ) ],
|
2012-01-09 22:33:00 +00:00
|
|
|
'wgDefaultLanguageVariant' => $variant,
|
|
|
|
|
'wgLinkHolderBatchSize' => $linkHolderBatchSize,
|
2016-09-09 07:28:49 +00:00
|
|
|
// Set as a JSON object like:
|
|
|
|
|
// wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
|
|
|
|
|
'wgEnableMagicLinks' => self::getOptionValue( 'wgEnableMagicLinks', $opts, [] )
|
|
|
|
|
+ [ 'ISBN' => true, 'PMID' => true, 'RFC' => true ],
|
2017-06-30 00:13:12 +00:00
|
|
|
// Test with legacy encoding by default until HTML5 is very stable and default
|
|
|
|
|
'wgFragmentMode' => [ 'legacy' ],
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2012-01-09 22:33:00 +00:00
|
|
|
|
ParserTestRunner: Fix handling of externallinktarget option
* There are two places in the parser test runner where test options
are processed: perTestSetup, and setupParserOptions. There isn't
enough guidance as to what should be set up where and why.
But, anything that is really a wiki config/global should ideally
be set up in perTestSetup because the ParserOptions object loads
all its defaults from the config values anyway.
* Parsoid gets wiki-specific options from SiteConfig and page-specific
options from PageConfig.
In 61c14054, "externallinktarget" was treated as a wiki-specific opt
by adding it to SiteConfig. So, if Parsoid is to see a test opt,
(a) the corresponding config/global should be initialized
(b) it should be processed before SiteConfig is constructed
* So, all that said, any test option that impacts Parsoid's SiteConfig
should therefore be set in perTestSetup as well whch also matches
my understanding of how it should be set up for legacy tests as well.
* This fix now ensures that external link target tests pass in Parsoid's
integrated mode as well.
* Based on above, couple other things that I'll fix up in followups:
- There are a couple other configs (maxtemplatedepth, maxincludesize)
that are being initialized in setupParserOptions which should
probably be moved to perTestSetup.
- runLegacyTest calls perTestSetup and setupParserOptions back-to-back
but runParsoidTest doesn't do that. Those are separated by code
that sets up SiteConfig and DataAccess. This shouldn't matter if the
above guidelines for initialization are followed appropriately,
but just for consistency's sake, I might try to move those two
closer together in another followup.
Followup-To: f7d6c0190d18d2337080f041a4a64efd45737236
Change-Id: I776b22a973fbcc945106fbe807376b858dd79e48
2022-09-26 21:16:14 +00:00
|
|
|
if ( isset( $opts['externallinktarget'] ) ) {
|
|
|
|
|
$setup['wgExternalLinkTarget'] = self::getOptionValue( 'externallinktarget', $opts, '' );
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-27 05:57:55 +00:00
|
|
|
$nonIncludable = self::getOptionValue( 'wgNonincludableNamespaces', $opts, false );
|
|
|
|
|
if ( $nonIncludable !== false ) {
|
|
|
|
|
$setup['wgNonincludableNamespaces'] = [ $nonIncludable ];
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-27 15:09:32 +00:00
|
|
|
if ( $test->config ) {
|
|
|
|
|
foreach ( $test->config as $var => $value ) {
|
|
|
|
|
$setup[$var] = $value;
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 14:55:28 +00:00
|
|
|
/** @since 1.20 */
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
Hooks::runner()->onParserTestGlobals( $setup );
|
2012-08-20 14:55:28 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// Set content language. This invalidates the magic word cache and title services
|
2020-04-16 18:14:42 +00:00
|
|
|
// In addition the ParserFactory needs to be recreated as well.
|
2019-08-26 12:24:37 +00:00
|
|
|
$lang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( $langCode );
|
2021-02-06 19:40:52 +00:00
|
|
|
$setup[] = static function () use ( $lang ) {
|
2018-07-25 14:37:16 +00:00
|
|
|
MediaWikiServices::getInstance()->disableService( 'ContentLanguage' );
|
|
|
|
|
MediaWikiServices::getInstance()->redefineService(
|
|
|
|
|
'ContentLanguage',
|
2021-02-07 13:10:36 +00:00
|
|
|
static function () use ( $lang ) {
|
2018-07-25 14:37:16 +00:00
|
|
|
return $lang;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
};
|
2021-02-06 19:40:52 +00:00
|
|
|
$teardown[] = static function () {
|
2018-07-25 14:37:16 +00:00
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'ContentLanguage' );
|
|
|
|
|
};
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$reset = function () {
|
2020-09-17 00:31:54 +00:00
|
|
|
$mwServices = MediaWikiServices::getInstance();
|
|
|
|
|
$mwServices->resetServiceForTesting( 'MagicWordFactory' );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$this->resetTitleServices();
|
2020-09-17 00:31:54 +00:00
|
|
|
$mwServices->resetServiceForTesting( 'ParserFactory' );
|
|
|
|
|
// If !!config touches $wgUsePigLatinVariant or the local wiki
|
|
|
|
|
// defaults to $wgUsePigLatinVariant=true, these need to be reset
|
|
|
|
|
$mwServices->resetServiceForTesting( 'LanguageConverterFactory' );
|
|
|
|
|
$mwServices->resetServiceForTesting( 'LanguageFactory' );
|
|
|
|
|
$mwServices->resetServiceForTesting( 'LanguageNameUtils' );
|
2022-06-05 04:09:27 +00:00
|
|
|
// The SiteConfig depends on the content language as well
|
|
|
|
|
// as the config vars in SiteConfig::CONSTRUCTOR_OPTIONS,
|
|
|
|
|
// so reset it as well.
|
|
|
|
|
// T310283: be more selective about resetting SiteConfig if
|
|
|
|
|
// performance is a concern.
|
|
|
|
|
$mwServices->resetServiceForTesting( 'ParsoidSiteConfig' );
|
2022-06-16 03:54:45 +00:00
|
|
|
// DataAccess depends on config vars, so reset it
|
|
|
|
|
$mwServices->resetServiceForTesting( 'ParsoidDataAccess' );
|
2022-08-30 22:27:37 +00:00
|
|
|
// Tidy service depends on $wgParserEnableLegacyMediaDOM, which can
|
|
|
|
|
// be configured per test
|
|
|
|
|
$mwServices->resetServiceForTesting( 'Tidy' );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
};
|
|
|
|
|
$setup[] = $reset;
|
|
|
|
|
$teardown[] = $reset;
|
|
|
|
|
|
2021-09-10 14:06:51 +00:00
|
|
|
$userOptionsManager = MediaWikiServices::getInstance()->getUserOptionsManager();
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// Make a user object with the same language
|
|
|
|
|
$user = new User;
|
2021-09-10 14:06:51 +00:00
|
|
|
$userOptionsManager->setOption( $user, 'language', $langCode );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$setup['wgLang'] = $lang;
|
|
|
|
|
$setup['wgUser'] = $user;
|
2012-01-09 22:33:00 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// And put both user and language into the context
|
|
|
|
|
$context = RequestContext::getMain();
|
|
|
|
|
$context->setUser( $user );
|
|
|
|
|
$context->setLanguage( $lang );
|
2017-07-20 01:42:56 +00:00
|
|
|
// And the skin!
|
|
|
|
|
$oldSkin = $context->getSkin();
|
|
|
|
|
$skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
|
|
|
|
|
$context->setSkin( $skinFactory->makeSkin( $skin ) );
|
|
|
|
|
$context->setOutput( new OutputPage( $context ) );
|
|
|
|
|
$setup['wgOut'] = $context->getOutput();
|
2021-02-06 19:40:52 +00:00
|
|
|
$teardown[] = static function () use ( $context, $oldSkin ) {
|
2017-06-26 17:56:30 +00:00
|
|
|
// Clear language conversion tables
|
2017-06-27 21:09:12 +00:00
|
|
|
$wrapper = TestingAccessWrapper::newFromObject(
|
2020-01-23 18:39:23 +00:00
|
|
|
MediaWikiServices::getInstance()->getLanguageConverterFactory()
|
|
|
|
|
->getLanguageConverter( $context->getLanguage() )
|
2017-06-27 21:09:12 +00:00
|
|
|
);
|
2022-02-24 19:57:59 +00:00
|
|
|
@$wrapper->reloadTables();
|
2020-01-29 15:13:08 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// Reset context to the restored globals
|
2021-09-04 19:19:47 +00:00
|
|
|
$context->setUser( StubGlobalUser::getRealUser( $GLOBALS['wgUser'] ) );
|
2017-07-20 01:42:56 +00:00
|
|
|
$context->setSkin( $oldSkin );
|
|
|
|
|
$context->setOutput( $GLOBALS['wgOut'] );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
};
|
2012-01-09 22:33:00 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$teardown[] = $this->executeSetupSnippets( $setup );
|
2016-04-25 05:41:32 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
return $this->createTeardownObject( $teardown, $nextTeardown );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* Set up temporary DB tables.
|
|
|
|
|
*
|
|
|
|
|
* For best performance, call this once only for all tests. However, it can
|
|
|
|
|
* be called at the start of each test if more isolation is desired.
|
|
|
|
|
*
|
|
|
|
|
*
|
2020-12-23 18:52:12 +00:00
|
|
|
* Do not call this function from a MediaWikiIntegrationTestCase subclass,
|
|
|
|
|
* since MediaWikiIntegrationTestCase does its own DB setup.
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
*
|
|
|
|
|
* @see staticSetup() for more information about setup/teardown
|
|
|
|
|
*
|
|
|
|
|
* @param ScopedCallback|null $nextTeardown The next teardown object
|
|
|
|
|
* @return ScopedCallback The teardown object
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
public function setupDatabase( $nextTeardown = null ) {
|
2012-01-09 22:33:00 +00:00
|
|
|
global $wgDBprefix;
|
|
|
|
|
|
2020-12-23 18:52:12 +00:00
|
|
|
$lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
|
2022-06-21 20:29:51 +00:00
|
|
|
$this->db = $lb->getConnectionInternal( DB_PRIMARY );
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2020-12-23 18:52:12 +00:00
|
|
|
$suspiciousPrefixes = [ self::DB_PREFIX, MediaWikiIntegrationTestCase::DB_PREFIX ];
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
if ( in_array( $wgDBprefix, $suspiciousPrefixes ) ) {
|
|
|
|
|
throw new MWException( "\$wgDBprefix=$wgDBprefix suggests DB setup is already done" );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$teardown = [];
|
|
|
|
|
$teardown[] = $this->markSetupDone( 'setupDatabase' );
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2020-12-23 18:52:12 +00:00
|
|
|
// Set up a test DB just for parser tests
|
|
|
|
|
MediaWikiIntegrationTestCase::setupAllTestDBs(
|
|
|
|
|
$this->db,
|
|
|
|
|
self::DB_PREFIX,
|
|
|
|
|
true // postgres requires that we use temporary tables
|
|
|
|
|
);
|
|
|
|
|
MediaWikiIntegrationTestCase::resetNonServiceCaches();
|
2021-02-06 19:40:52 +00:00
|
|
|
$teardown[] = static function () {
|
2020-12-23 18:52:12 +00:00
|
|
|
MediaWikiIntegrationTestCase::teardownTestDB();
|
|
|
|
|
};
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2020-12-23 18:52:12 +00:00
|
|
|
MediaWikiIntegrationTestCase::installMockMwServices();
|
2021-02-06 19:40:52 +00:00
|
|
|
$teardown[] = static function () {
|
2020-12-23 18:52:12 +00:00
|
|
|
MediaWikiIntegrationTestCase::restoreMwServices();
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Wipe some DB query result caches on setup and teardown
|
2021-02-06 19:40:52 +00:00
|
|
|
$reset = static function () {
|
2020-03-14 12:58:53 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
$services->getLinkCache()->clear();
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
|
|
|
|
|
// Clear the message cache
|
2020-03-14 12:58:53 +00:00
|
|
|
$services->getMessageCache()->clear();
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
};
|
|
|
|
|
$reset();
|
|
|
|
|
$teardown[] = $reset;
|
|
|
|
|
return $this->createTeardownObject( $teardown, $nextTeardown );
|
|
|
|
|
}
|
2012-01-09 22:33:00 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
/**
|
|
|
|
|
* Add data about uploads to the new test DB, and set up the upload
|
2020-12-23 18:52:12 +00:00
|
|
|
* directory. This should be called after setupDatabase().
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
*
|
|
|
|
|
* @param ScopedCallback|null $nextTeardown The next teardown object
|
|
|
|
|
* @return ScopedCallback The teardown object
|
|
|
|
|
*/
|
|
|
|
|
public function setupUploads( $nextTeardown = null ) {
|
|
|
|
|
$teardown = [];
|
|
|
|
|
|
2020-12-23 18:52:12 +00:00
|
|
|
$this->checkSetupDone( 'setupDatabase' );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$teardown[] = $this->markSetupDone( 'setupUploads' );
|
2012-01-09 22:33:00 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// Create the files in the upload directory (or pretend to create them
|
|
|
|
|
// in a MockFileBackend). Append teardown callback.
|
|
|
|
|
$teardown[] = $this->setupUploadBackend();
|
2012-01-09 22:33:00 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// Create a user
|
2012-01-09 22:33:00 +00:00
|
|
|
$user = User::createNew( 'WikiSysop' );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
|
|
|
|
|
// Register the uploads in the database
|
2020-03-08 21:47:14 +00:00
|
|
|
$localRepo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
|
2020-03-08 21:47:14 +00:00
|
|
|
$image = $localRepo->newFile( Title::makeTitle( NS_FILE, 'Foobar.jpg' ) );
|
2013-02-27 00:12:12 +00:00
|
|
|
# note that the size/width/height/bits/etc of the file
|
|
|
|
|
# are actually set by inspecting the file itself; the arguments
|
2020-06-16 01:45:46 +00:00
|
|
|
# to recordUpload3 have no effect. That said, we try to make things
|
2013-02-27 00:12:12 +00:00
|
|
|
# match up so it is less confusing to readers of the code & tests.
|
2020-06-16 01:45:46 +00:00
|
|
|
$image->recordUpload3(
|
|
|
|
|
'',
|
|
|
|
|
'Upload of some lame file', 'Some lame file',
|
|
|
|
|
$user,
|
|
|
|
|
[
|
|
|
|
|
'size' => 7881,
|
|
|
|
|
'width' => 1941,
|
|
|
|
|
'height' => 220,
|
|
|
|
|
'bits' => 8,
|
|
|
|
|
'media_type' => MEDIATYPE_BITMAP,
|
|
|
|
|
'mime' => 'image/jpeg',
|
Use the unserialized form of image metadata internally
Image metadata is usually a serialized string representing an array.
Passing the string around internally and having everything unserialize
it is an awkward convention.
Also, many image handlers were reading the file twice: once for
getMetadata() and again for getImageSize(). Often getMetadata()
would actually read the width and height and then throw it away.
So, in filerepo:
* Add File::getMetadataItem(), which promises to allow partial
loading of metadata per my proposal on T275268 in a future commit.
* Add File::getMetadataArray(), which returns the unserialized array.
Some file handlers were returning non-serializable strings from
getMetadata(), so I gave them a legacy array form ['_error' => ...]
* Changed MWFileProps to return the array form of metadata.
* Deprecate the weird File::getImageSize(). It was apparently not
called by anything, but was overridden by UnregisteredLocalFile.
* Wrap serialize/unserialize with File::getMetadataForDb() and
File::loadMetadataFromDb() in preparation for T275268.
In MediaHandler:
* Merged MediaHandler::getImageSize() and MediaHandler::getMetadata()
into getSizeAndMetadata(). Deprecated the old methods.
* Instead of isMetadataValid() we now have isFileMetadataValid(), which
only gets a File object, so it can decide what data it needs to load.
* Simplified getPageDimensions() by having it return false for non-paged
media. It was not called in that case, but was implemented anyway.
In specific handlers:
* Rename DjVuHandler::getUnserializedMetadata() and
extractTreesFromMetadata() for clarity. "Metadata" in these function
names meant an XML string.
* Updated DjVuImage::getImageSize() to provide image sizes in the new
style.
* In ExifBitmapHandler, getRotationForExif() now takes just the
Orientation tag, rather than a serialized string. Also renamed for
clarity.
* In GIFMetadataExtractor, return the width, height and bits per channel
instead of throwing them away. There was some conflation in
decodeBPP() which I picked apart. Refer to GIF89a section 18.
* In JpegMetadataExtractor, process the SOF0/SOF2 segment to extract
bits per channel, width, height and components (channel count). This
is essentially a port of PHP's getimagesize(), so should be bugwards
compatible.
* In PNGMetadataExtractor, return the width and height, which were
previously assigned to unused local variables. I verified the
implementation by referring to the specification.
* In SvgHandler, retain the version validation from unpackMetadata(),
but rename the function since it now takes an array as input.
In tests:
* In ExifBitmapTest, refactored some tests by using a provider.
* In GIFHandlerTest and PNGHandlerTest, I removed the tests in which
getMetadata() returns null, since it doesn't make sense when ported to
getMetadataArray(). I added tests for empty arrays instead.
* In tests, I retained serialization of input data since I figure it's
useful to confirm that existing database rows will continue to be read
correctly. I removed serialization of expected values, replacing them
with plain data.
* In tests, I replaced access to private class constants like
BROKEN_FILE with string literals, since stability is essential. If
the class constant changes, the test should fail.
Elsewhere:
* In maintenance/refreshImageMetadata.php, I removed the check for
shrinking image metadata, since it's not easy to implement and is
not future compatible. Image metadata is expected to shrink in
future.
Bug: T275268
Change-Id: I039785d5b6439d71dcc21dcb972177dba5c3a67d
2021-05-19 00:24:32 +00:00
|
|
|
'metadata' => [],
|
2020-06-16 01:45:46 +00:00
|
|
|
'sha1' => Wikimedia\base_convert( '1', 16, 36, 31 ),
|
|
|
|
|
'fileExists' => true
|
|
|
|
|
],
|
|
|
|
|
$this->db->timestamp( '20010115123500' )
|
|
|
|
|
);
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2020-03-08 21:47:14 +00:00
|
|
|
$image = $localRepo->newFile( Title::makeTitle( NS_FILE, 'Thumb.png' ) );
|
2013-02-27 00:12:12 +00:00
|
|
|
# again, note that size/width/height below are ignored; see above.
|
2020-06-16 01:45:46 +00:00
|
|
|
$image->recordUpload3(
|
|
|
|
|
'',
|
|
|
|
|
'Upload of some lame thumbnail',
|
|
|
|
|
'Some lame thumbnail',
|
|
|
|
|
$user,
|
|
|
|
|
[
|
|
|
|
|
'size' => 22589,
|
|
|
|
|
'width' => 135,
|
|
|
|
|
'height' => 135,
|
|
|
|
|
'bits' => 8,
|
|
|
|
|
'media_type' => MEDIATYPE_BITMAP,
|
|
|
|
|
'mime' => 'image/png',
|
Use the unserialized form of image metadata internally
Image metadata is usually a serialized string representing an array.
Passing the string around internally and having everything unserialize
it is an awkward convention.
Also, many image handlers were reading the file twice: once for
getMetadata() and again for getImageSize(). Often getMetadata()
would actually read the width and height and then throw it away.
So, in filerepo:
* Add File::getMetadataItem(), which promises to allow partial
loading of metadata per my proposal on T275268 in a future commit.
* Add File::getMetadataArray(), which returns the unserialized array.
Some file handlers were returning non-serializable strings from
getMetadata(), so I gave them a legacy array form ['_error' => ...]
* Changed MWFileProps to return the array form of metadata.
* Deprecate the weird File::getImageSize(). It was apparently not
called by anything, but was overridden by UnregisteredLocalFile.
* Wrap serialize/unserialize with File::getMetadataForDb() and
File::loadMetadataFromDb() in preparation for T275268.
In MediaHandler:
* Merged MediaHandler::getImageSize() and MediaHandler::getMetadata()
into getSizeAndMetadata(). Deprecated the old methods.
* Instead of isMetadataValid() we now have isFileMetadataValid(), which
only gets a File object, so it can decide what data it needs to load.
* Simplified getPageDimensions() by having it return false for non-paged
media. It was not called in that case, but was implemented anyway.
In specific handlers:
* Rename DjVuHandler::getUnserializedMetadata() and
extractTreesFromMetadata() for clarity. "Metadata" in these function
names meant an XML string.
* Updated DjVuImage::getImageSize() to provide image sizes in the new
style.
* In ExifBitmapHandler, getRotationForExif() now takes just the
Orientation tag, rather than a serialized string. Also renamed for
clarity.
* In GIFMetadataExtractor, return the width, height and bits per channel
instead of throwing them away. There was some conflation in
decodeBPP() which I picked apart. Refer to GIF89a section 18.
* In JpegMetadataExtractor, process the SOF0/SOF2 segment to extract
bits per channel, width, height and components (channel count). This
is essentially a port of PHP's getimagesize(), so should be bugwards
compatible.
* In PNGMetadataExtractor, return the width and height, which were
previously assigned to unused local variables. I verified the
implementation by referring to the specification.
* In SvgHandler, retain the version validation from unpackMetadata(),
but rename the function since it now takes an array as input.
In tests:
* In ExifBitmapTest, refactored some tests by using a provider.
* In GIFHandlerTest and PNGHandlerTest, I removed the tests in which
getMetadata() returns null, since it doesn't make sense when ported to
getMetadataArray(). I added tests for empty arrays instead.
* In tests, I retained serialization of input data since I figure it's
useful to confirm that existing database rows will continue to be read
correctly. I removed serialization of expected values, replacing them
with plain data.
* In tests, I replaced access to private class constants like
BROKEN_FILE with string literals, since stability is essential. If
the class constant changes, the test should fail.
Elsewhere:
* In maintenance/refreshImageMetadata.php, I removed the check for
shrinking image metadata, since it's not easy to implement and is
not future compatible. Image metadata is expected to shrink in
future.
Bug: T275268
Change-Id: I039785d5b6439d71dcc21dcb972177dba5c3a67d
2021-05-19 00:24:32 +00:00
|
|
|
'metadata' => [],
|
2020-06-16 01:45:46 +00:00
|
|
|
'sha1' => Wikimedia\base_convert( '2', 16, 36, 31 ),
|
|
|
|
|
'fileExists' => true
|
|
|
|
|
],
|
|
|
|
|
$this->db->timestamp( '20130225203040' )
|
|
|
|
|
);
|
2013-02-27 00:12:12 +00:00
|
|
|
|
2020-03-08 21:47:14 +00:00
|
|
|
$image = $localRepo->newFile( Title::makeTitle( NS_FILE, 'Foobar.svg' ) );
|
2020-06-16 01:45:46 +00:00
|
|
|
$image->recordUpload3(
|
|
|
|
|
'',
|
|
|
|
|
'Upload of some lame SVG',
|
|
|
|
|
'Some lame SVG',
|
|
|
|
|
$user,
|
|
|
|
|
[
|
2013-05-24 12:56:06 +00:00
|
|
|
'size' => 12345,
|
|
|
|
|
'width' => 240,
|
|
|
|
|
'height' => 180,
|
2014-06-03 19:44:53 +00:00
|
|
|
'bits' => 0,
|
2013-05-24 12:56:06 +00:00
|
|
|
'media_type' => MEDIATYPE_DRAWING,
|
|
|
|
|
'mime' => 'image/svg+xml',
|
Use the unserialized form of image metadata internally
Image metadata is usually a serialized string representing an array.
Passing the string around internally and having everything unserialize
it is an awkward convention.
Also, many image handlers were reading the file twice: once for
getMetadata() and again for getImageSize(). Often getMetadata()
would actually read the width and height and then throw it away.
So, in filerepo:
* Add File::getMetadataItem(), which promises to allow partial
loading of metadata per my proposal on T275268 in a future commit.
* Add File::getMetadataArray(), which returns the unserialized array.
Some file handlers were returning non-serializable strings from
getMetadata(), so I gave them a legacy array form ['_error' => ...]
* Changed MWFileProps to return the array form of metadata.
* Deprecate the weird File::getImageSize(). It was apparently not
called by anything, but was overridden by UnregisteredLocalFile.
* Wrap serialize/unserialize with File::getMetadataForDb() and
File::loadMetadataFromDb() in preparation for T275268.
In MediaHandler:
* Merged MediaHandler::getImageSize() and MediaHandler::getMetadata()
into getSizeAndMetadata(). Deprecated the old methods.
* Instead of isMetadataValid() we now have isFileMetadataValid(), which
only gets a File object, so it can decide what data it needs to load.
* Simplified getPageDimensions() by having it return false for non-paged
media. It was not called in that case, but was implemented anyway.
In specific handlers:
* Rename DjVuHandler::getUnserializedMetadata() and
extractTreesFromMetadata() for clarity. "Metadata" in these function
names meant an XML string.
* Updated DjVuImage::getImageSize() to provide image sizes in the new
style.
* In ExifBitmapHandler, getRotationForExif() now takes just the
Orientation tag, rather than a serialized string. Also renamed for
clarity.
* In GIFMetadataExtractor, return the width, height and bits per channel
instead of throwing them away. There was some conflation in
decodeBPP() which I picked apart. Refer to GIF89a section 18.
* In JpegMetadataExtractor, process the SOF0/SOF2 segment to extract
bits per channel, width, height and components (channel count). This
is essentially a port of PHP's getimagesize(), so should be bugwards
compatible.
* In PNGMetadataExtractor, return the width and height, which were
previously assigned to unused local variables. I verified the
implementation by referring to the specification.
* In SvgHandler, retain the version validation from unpackMetadata(),
but rename the function since it now takes an array as input.
In tests:
* In ExifBitmapTest, refactored some tests by using a provider.
* In GIFHandlerTest and PNGHandlerTest, I removed the tests in which
getMetadata() returns null, since it doesn't make sense when ported to
getMetadataArray(). I added tests for empty arrays instead.
* In tests, I retained serialization of input data since I figure it's
useful to confirm that existing database rows will continue to be read
correctly. I removed serialization of expected values, replacing them
with plain data.
* In tests, I replaced access to private class constants like
BROKEN_FILE with string literals, since stability is essential. If
the class constant changes, the test should fail.
Elsewhere:
* In maintenance/refreshImageMetadata.php, I removed the check for
shrinking image metadata, since it's not easy to implement and is
not future compatible. Image metadata is expected to shrink in
future.
Bug: T275268
Change-Id: I039785d5b6439d71dcc21dcb972177dba5c3a67d
2021-05-19 00:24:32 +00:00
|
|
|
'metadata' => [
|
2018-10-06 00:56:53 +00:00
|
|
|
'version' => SvgHandler::SVG_METADATA_VERSION,
|
|
|
|
|
'width' => 240,
|
|
|
|
|
'height' => 180,
|
|
|
|
|
'originalWidth' => '100%',
|
|
|
|
|
'originalHeight' => '100%',
|
|
|
|
|
'translations' => [
|
|
|
|
|
'en' => SVGReader::LANG_FULL_MATCH,
|
|
|
|
|
'ru' => SVGReader::LANG_FULL_MATCH,
|
|
|
|
|
],
|
Use the unserialized form of image metadata internally
Image metadata is usually a serialized string representing an array.
Passing the string around internally and having everything unserialize
it is an awkward convention.
Also, many image handlers were reading the file twice: once for
getMetadata() and again for getImageSize(). Often getMetadata()
would actually read the width and height and then throw it away.
So, in filerepo:
* Add File::getMetadataItem(), which promises to allow partial
loading of metadata per my proposal on T275268 in a future commit.
* Add File::getMetadataArray(), which returns the unserialized array.
Some file handlers were returning non-serializable strings from
getMetadata(), so I gave them a legacy array form ['_error' => ...]
* Changed MWFileProps to return the array form of metadata.
* Deprecate the weird File::getImageSize(). It was apparently not
called by anything, but was overridden by UnregisteredLocalFile.
* Wrap serialize/unserialize with File::getMetadataForDb() and
File::loadMetadataFromDb() in preparation for T275268.
In MediaHandler:
* Merged MediaHandler::getImageSize() and MediaHandler::getMetadata()
into getSizeAndMetadata(). Deprecated the old methods.
* Instead of isMetadataValid() we now have isFileMetadataValid(), which
only gets a File object, so it can decide what data it needs to load.
* Simplified getPageDimensions() by having it return false for non-paged
media. It was not called in that case, but was implemented anyway.
In specific handlers:
* Rename DjVuHandler::getUnserializedMetadata() and
extractTreesFromMetadata() for clarity. "Metadata" in these function
names meant an XML string.
* Updated DjVuImage::getImageSize() to provide image sizes in the new
style.
* In ExifBitmapHandler, getRotationForExif() now takes just the
Orientation tag, rather than a serialized string. Also renamed for
clarity.
* In GIFMetadataExtractor, return the width, height and bits per channel
instead of throwing them away. There was some conflation in
decodeBPP() which I picked apart. Refer to GIF89a section 18.
* In JpegMetadataExtractor, process the SOF0/SOF2 segment to extract
bits per channel, width, height and components (channel count). This
is essentially a port of PHP's getimagesize(), so should be bugwards
compatible.
* In PNGMetadataExtractor, return the width and height, which were
previously assigned to unused local variables. I verified the
implementation by referring to the specification.
* In SvgHandler, retain the version validation from unpackMetadata(),
but rename the function since it now takes an array as input.
In tests:
* In ExifBitmapTest, refactored some tests by using a provider.
* In GIFHandlerTest and PNGHandlerTest, I removed the tests in which
getMetadata() returns null, since it doesn't make sense when ported to
getMetadataArray(). I added tests for empty arrays instead.
* In tests, I retained serialization of input data since I figure it's
useful to confirm that existing database rows will continue to be read
correctly. I removed serialization of expected values, replacing them
with plain data.
* In tests, I replaced access to private class constants like
BROKEN_FILE with string literals, since stability is essential. If
the class constant changes, the test should fail.
Elsewhere:
* In maintenance/refreshImageMetadata.php, I removed the check for
shrinking image metadata, since it's not easy to implement and is
not future compatible. Image metadata is expected to shrink in
future.
Bug: T275268
Change-Id: I039785d5b6439d71dcc21dcb972177dba5c3a67d
2021-05-19 00:24:32 +00:00
|
|
|
],
|
2015-11-24 22:51:42 +00:00
|
|
|
'sha1' => Wikimedia\base_convert( '', 16, 36, 31 ),
|
2013-05-24 12:56:06 +00:00
|
|
|
'fileExists' => true
|
2020-06-16 01:45:46 +00:00
|
|
|
],
|
|
|
|
|
$this->db->timestamp( '20010115123500' )
|
|
|
|
|
);
|
2013-05-24 12:56:06 +00:00
|
|
|
|
2021-03-29 04:22:24 +00:00
|
|
|
# This image will be prohibited via the list in [[MediaWiki:Bad image list]]
|
2020-03-08 21:47:14 +00:00
|
|
|
$image = $localRepo->newFile( Title::makeTitle( NS_FILE, 'Bad.jpg' ) );
|
2020-06-16 01:45:46 +00:00
|
|
|
$image->recordUpload3(
|
|
|
|
|
'',
|
|
|
|
|
'zomgnotcensored',
|
|
|
|
|
'Borderline image',
|
|
|
|
|
$user,
|
|
|
|
|
[
|
|
|
|
|
'size' => 12345,
|
|
|
|
|
'width' => 320,
|
|
|
|
|
'height' => 240,
|
|
|
|
|
'bits' => 24,
|
|
|
|
|
'media_type' => MEDIATYPE_BITMAP,
|
|
|
|
|
'mime' => 'image/jpeg',
|
Use the unserialized form of image metadata internally
Image metadata is usually a serialized string representing an array.
Passing the string around internally and having everything unserialize
it is an awkward convention.
Also, many image handlers were reading the file twice: once for
getMetadata() and again for getImageSize(). Often getMetadata()
would actually read the width and height and then throw it away.
So, in filerepo:
* Add File::getMetadataItem(), which promises to allow partial
loading of metadata per my proposal on T275268 in a future commit.
* Add File::getMetadataArray(), which returns the unserialized array.
Some file handlers were returning non-serializable strings from
getMetadata(), so I gave them a legacy array form ['_error' => ...]
* Changed MWFileProps to return the array form of metadata.
* Deprecate the weird File::getImageSize(). It was apparently not
called by anything, but was overridden by UnregisteredLocalFile.
* Wrap serialize/unserialize with File::getMetadataForDb() and
File::loadMetadataFromDb() in preparation for T275268.
In MediaHandler:
* Merged MediaHandler::getImageSize() and MediaHandler::getMetadata()
into getSizeAndMetadata(). Deprecated the old methods.
* Instead of isMetadataValid() we now have isFileMetadataValid(), which
only gets a File object, so it can decide what data it needs to load.
* Simplified getPageDimensions() by having it return false for non-paged
media. It was not called in that case, but was implemented anyway.
In specific handlers:
* Rename DjVuHandler::getUnserializedMetadata() and
extractTreesFromMetadata() for clarity. "Metadata" in these function
names meant an XML string.
* Updated DjVuImage::getImageSize() to provide image sizes in the new
style.
* In ExifBitmapHandler, getRotationForExif() now takes just the
Orientation tag, rather than a serialized string. Also renamed for
clarity.
* In GIFMetadataExtractor, return the width, height and bits per channel
instead of throwing them away. There was some conflation in
decodeBPP() which I picked apart. Refer to GIF89a section 18.
* In JpegMetadataExtractor, process the SOF0/SOF2 segment to extract
bits per channel, width, height and components (channel count). This
is essentially a port of PHP's getimagesize(), so should be bugwards
compatible.
* In PNGMetadataExtractor, return the width and height, which were
previously assigned to unused local variables. I verified the
implementation by referring to the specification.
* In SvgHandler, retain the version validation from unpackMetadata(),
but rename the function since it now takes an array as input.
In tests:
* In ExifBitmapTest, refactored some tests by using a provider.
* In GIFHandlerTest and PNGHandlerTest, I removed the tests in which
getMetadata() returns null, since it doesn't make sense when ported to
getMetadataArray(). I added tests for empty arrays instead.
* In tests, I retained serialization of input data since I figure it's
useful to confirm that existing database rows will continue to be read
correctly. I removed serialization of expected values, replacing them
with plain data.
* In tests, I replaced access to private class constants like
BROKEN_FILE with string literals, since stability is essential. If
the class constant changes, the test should fail.
Elsewhere:
* In maintenance/refreshImageMetadata.php, I removed the check for
shrinking image metadata, since it's not easy to implement and is
not future compatible. Image metadata is expected to shrink in
future.
Bug: T275268
Change-Id: I039785d5b6439d71dcc21dcb972177dba5c3a67d
2021-05-19 00:24:32 +00:00
|
|
|
'metadata' => [],
|
2020-06-16 01:45:46 +00:00
|
|
|
'sha1' => Wikimedia\base_convert( '3', 16, 36, 31 ),
|
|
|
|
|
'fileExists' => true
|
|
|
|
|
],
|
|
|
|
|
$this->db->timestamp( '20010115123500' )
|
|
|
|
|
);
|
2013-12-18 17:56:15 +00:00
|
|
|
|
2020-03-08 21:47:14 +00:00
|
|
|
$image = $localRepo->newFile( Title::makeTitle( NS_FILE, 'Video.ogv' ) );
|
2020-06-16 01:45:46 +00:00
|
|
|
$image->recordUpload3(
|
|
|
|
|
'',
|
|
|
|
|
'A pretty movie',
|
|
|
|
|
'Will it play',
|
|
|
|
|
$user,
|
|
|
|
|
[
|
|
|
|
|
'size' => 12345,
|
|
|
|
|
'width' => 320,
|
|
|
|
|
'height' => 240,
|
|
|
|
|
'bits' => 0,
|
|
|
|
|
'media_type' => MEDIATYPE_VIDEO,
|
|
|
|
|
'mime' => 'application/ogg',
|
Use the unserialized form of image metadata internally
Image metadata is usually a serialized string representing an array.
Passing the string around internally and having everything unserialize
it is an awkward convention.
Also, many image handlers were reading the file twice: once for
getMetadata() and again for getImageSize(). Often getMetadata()
would actually read the width and height and then throw it away.
So, in filerepo:
* Add File::getMetadataItem(), which promises to allow partial
loading of metadata per my proposal on T275268 in a future commit.
* Add File::getMetadataArray(), which returns the unserialized array.
Some file handlers were returning non-serializable strings from
getMetadata(), so I gave them a legacy array form ['_error' => ...]
* Changed MWFileProps to return the array form of metadata.
* Deprecate the weird File::getImageSize(). It was apparently not
called by anything, but was overridden by UnregisteredLocalFile.
* Wrap serialize/unserialize with File::getMetadataForDb() and
File::loadMetadataFromDb() in preparation for T275268.
In MediaHandler:
* Merged MediaHandler::getImageSize() and MediaHandler::getMetadata()
into getSizeAndMetadata(). Deprecated the old methods.
* Instead of isMetadataValid() we now have isFileMetadataValid(), which
only gets a File object, so it can decide what data it needs to load.
* Simplified getPageDimensions() by having it return false for non-paged
media. It was not called in that case, but was implemented anyway.
In specific handlers:
* Rename DjVuHandler::getUnserializedMetadata() and
extractTreesFromMetadata() for clarity. "Metadata" in these function
names meant an XML string.
* Updated DjVuImage::getImageSize() to provide image sizes in the new
style.
* In ExifBitmapHandler, getRotationForExif() now takes just the
Orientation tag, rather than a serialized string. Also renamed for
clarity.
* In GIFMetadataExtractor, return the width, height and bits per channel
instead of throwing them away. There was some conflation in
decodeBPP() which I picked apart. Refer to GIF89a section 18.
* In JpegMetadataExtractor, process the SOF0/SOF2 segment to extract
bits per channel, width, height and components (channel count). This
is essentially a port of PHP's getimagesize(), so should be bugwards
compatible.
* In PNGMetadataExtractor, return the width and height, which were
previously assigned to unused local variables. I verified the
implementation by referring to the specification.
* In SvgHandler, retain the version validation from unpackMetadata(),
but rename the function since it now takes an array as input.
In tests:
* In ExifBitmapTest, refactored some tests by using a provider.
* In GIFHandlerTest and PNGHandlerTest, I removed the tests in which
getMetadata() returns null, since it doesn't make sense when ported to
getMetadataArray(). I added tests for empty arrays instead.
* In tests, I retained serialization of input data since I figure it's
useful to confirm that existing database rows will continue to be read
correctly. I removed serialization of expected values, replacing them
with plain data.
* In tests, I replaced access to private class constants like
BROKEN_FILE with string literals, since stability is essential. If
the class constant changes, the test should fail.
Elsewhere:
* In maintenance/refreshImageMetadata.php, I removed the check for
shrinking image metadata, since it's not easy to implement and is
not future compatible. Image metadata is expected to shrink in
future.
Bug: T275268
Change-Id: I039785d5b6439d71dcc21dcb972177dba5c3a67d
2021-05-19 00:24:32 +00:00
|
|
|
'metadata' => [],
|
2020-06-16 01:45:46 +00:00
|
|
|
'sha1' => Wikimedia\base_convert( '', 16, 36, 31 ),
|
|
|
|
|
'fileExists' => true
|
|
|
|
|
],
|
|
|
|
|
$this->db->timestamp( '20010115123500' )
|
|
|
|
|
);
|
2016-01-07 08:41:23 +00:00
|
|
|
|
2020-03-08 21:47:14 +00:00
|
|
|
$image = $localRepo->newFile( Title::makeTitle( NS_FILE, 'Audio.oga' ) );
|
2020-06-16 01:45:46 +00:00
|
|
|
$image->recordUpload3(
|
|
|
|
|
'',
|
|
|
|
|
'An awesome hitsong',
|
|
|
|
|
'Will it play',
|
|
|
|
|
$user,
|
|
|
|
|
[
|
|
|
|
|
'size' => 12345,
|
|
|
|
|
'width' => 0,
|
|
|
|
|
'height' => 0,
|
|
|
|
|
'bits' => 0,
|
|
|
|
|
'media_type' => MEDIATYPE_AUDIO,
|
|
|
|
|
'mime' => 'application/ogg',
|
Use the unserialized form of image metadata internally
Image metadata is usually a serialized string representing an array.
Passing the string around internally and having everything unserialize
it is an awkward convention.
Also, many image handlers were reading the file twice: once for
getMetadata() and again for getImageSize(). Often getMetadata()
would actually read the width and height and then throw it away.
So, in filerepo:
* Add File::getMetadataItem(), which promises to allow partial
loading of metadata per my proposal on T275268 in a future commit.
* Add File::getMetadataArray(), which returns the unserialized array.
Some file handlers were returning non-serializable strings from
getMetadata(), so I gave them a legacy array form ['_error' => ...]
* Changed MWFileProps to return the array form of metadata.
* Deprecate the weird File::getImageSize(). It was apparently not
called by anything, but was overridden by UnregisteredLocalFile.
* Wrap serialize/unserialize with File::getMetadataForDb() and
File::loadMetadataFromDb() in preparation for T275268.
In MediaHandler:
* Merged MediaHandler::getImageSize() and MediaHandler::getMetadata()
into getSizeAndMetadata(). Deprecated the old methods.
* Instead of isMetadataValid() we now have isFileMetadataValid(), which
only gets a File object, so it can decide what data it needs to load.
* Simplified getPageDimensions() by having it return false for non-paged
media. It was not called in that case, but was implemented anyway.
In specific handlers:
* Rename DjVuHandler::getUnserializedMetadata() and
extractTreesFromMetadata() for clarity. "Metadata" in these function
names meant an XML string.
* Updated DjVuImage::getImageSize() to provide image sizes in the new
style.
* In ExifBitmapHandler, getRotationForExif() now takes just the
Orientation tag, rather than a serialized string. Also renamed for
clarity.
* In GIFMetadataExtractor, return the width, height and bits per channel
instead of throwing them away. There was some conflation in
decodeBPP() which I picked apart. Refer to GIF89a section 18.
* In JpegMetadataExtractor, process the SOF0/SOF2 segment to extract
bits per channel, width, height and components (channel count). This
is essentially a port of PHP's getimagesize(), so should be bugwards
compatible.
* In PNGMetadataExtractor, return the width and height, which were
previously assigned to unused local variables. I verified the
implementation by referring to the specification.
* In SvgHandler, retain the version validation from unpackMetadata(),
but rename the function since it now takes an array as input.
In tests:
* In ExifBitmapTest, refactored some tests by using a provider.
* In GIFHandlerTest and PNGHandlerTest, I removed the tests in which
getMetadata() returns null, since it doesn't make sense when ported to
getMetadataArray(). I added tests for empty arrays instead.
* In tests, I retained serialization of input data since I figure it's
useful to confirm that existing database rows will continue to be read
correctly. I removed serialization of expected values, replacing them
with plain data.
* In tests, I replaced access to private class constants like
BROKEN_FILE with string literals, since stability is essential. If
the class constant changes, the test should fail.
Elsewhere:
* In maintenance/refreshImageMetadata.php, I removed the check for
shrinking image metadata, since it's not easy to implement and is
not future compatible. Image metadata is expected to shrink in
future.
Bug: T275268
Change-Id: I039785d5b6439d71dcc21dcb972177dba5c3a67d
2021-05-19 00:24:32 +00:00
|
|
|
'metadata' => [],
|
2020-06-16 01:45:46 +00:00
|
|
|
'sha1' => Wikimedia\base_convert( '', 16, 36, 31 ),
|
|
|
|
|
'fileExists' => true
|
|
|
|
|
],
|
|
|
|
|
$this->db->timestamp( '20010115123500' )
|
|
|
|
|
);
|
2016-05-18 15:48:04 +00:00
|
|
|
|
2013-12-18 17:56:15 +00:00
|
|
|
# A DjVu file
|
2020-03-08 21:47:14 +00:00
|
|
|
$image = $localRepo->newFile( Title::makeTitle( NS_FILE, 'LoremIpsum.djvu' ) );
|
2021-11-21 08:50:59 +00:00
|
|
|
$djvuMetadata = [
|
|
|
|
|
'data' => [
|
|
|
|
|
'pages' => [
|
|
|
|
|
[ 'height' => 3508, 'width' => 2480, 'dpi' => 300, 'gamma' => 2.2 ],
|
|
|
|
|
[ 'height' => 3508, 'width' => 2480, 'dpi' => 300, 'gamma' => 2.2 ],
|
|
|
|
|
[ 'height' => 3508, 'width' => 2480, 'dpi' => 300, 'gamma' => 2.2 ],
|
|
|
|
|
[ 'height' => 3508, 'width' => 2480, 'dpi' => 300, 'gamma' => 2.2 ],
|
|
|
|
|
[ 'height' => 3508, 'width' => 2480, 'dpi' => 300, 'gamma' => 2.2 ],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2020-06-16 01:45:46 +00:00
|
|
|
$image->recordUpload3(
|
|
|
|
|
'',
|
|
|
|
|
'Upload a DjVu',
|
|
|
|
|
'A DjVu',
|
|
|
|
|
$user,
|
|
|
|
|
[
|
|
|
|
|
'size' => 3249,
|
|
|
|
|
'width' => 2480,
|
|
|
|
|
'height' => 3508,
|
|
|
|
|
'bits' => 0,
|
2020-12-21 16:52:41 +00:00
|
|
|
'media_type' => MEDIATYPE_OFFICE,
|
2020-06-16 01:45:46 +00:00
|
|
|
'mime' => 'image/vnd.djvu',
|
2021-11-21 08:50:59 +00:00
|
|
|
'metadata' => $djvuMetadata,
|
2020-06-16 01:45:46 +00:00
|
|
|
'sha1' => Wikimedia\base_convert( '', 16, 36, 31 ),
|
|
|
|
|
'fileExists' => true
|
|
|
|
|
],
|
|
|
|
|
$this->db->timestamp( '20010115123600' )
|
|
|
|
|
);
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
|
|
|
|
|
return $this->createTeardownObject( $teardown, $nextTeardown );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* Upload test files to the backend created by createRepoGroup().
|
2012-01-09 22:33:00 +00:00
|
|
|
*
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* @return callable The teardown callback
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
private function setupUploadBackend() {
|
2012-01-09 22:33:00 +00:00
|
|
|
global $IP;
|
|
|
|
|
|
2020-03-08 21:47:14 +00:00
|
|
|
$repo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$base = $repo->getZonePath( 'public' );
|
|
|
|
|
$backend = $repo->getBackend();
|
|
|
|
|
$backend->prepare( [ 'dir' => "$base/3/3a" ] );
|
2020-11-13 05:19:43 +00:00
|
|
|
$backend->quickStore( [
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
'src' => "$IP/tests/phpunit/data/parser/headbg.jpg",
|
|
|
|
|
'dst' => "$base/3/3a/Foobar.jpg"
|
|
|
|
|
] );
|
|
|
|
|
$backend->prepare( [ 'dir' => "$base/e/ea" ] );
|
2020-11-13 05:19:43 +00:00
|
|
|
$backend->quickStore( [
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
'src' => "$IP/tests/phpunit/data/parser/wiki.png",
|
|
|
|
|
'dst' => "$base/e/ea/Thumb.png"
|
|
|
|
|
] );
|
|
|
|
|
$backend->prepare( [ 'dir' => "$base/0/09" ] );
|
2020-11-13 05:19:43 +00:00
|
|
|
$backend->quickStore( [
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
'src' => "$IP/tests/phpunit/data/parser/headbg.jpg",
|
|
|
|
|
'dst' => "$base/0/09/Bad.jpg"
|
|
|
|
|
] );
|
|
|
|
|
$backend->prepare( [ 'dir' => "$base/5/5f" ] );
|
2020-11-13 05:19:43 +00:00
|
|
|
$backend->quickStore( [
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
'src' => "$IP/tests/phpunit/data/parser/LoremIpsum.djvu",
|
|
|
|
|
'dst' => "$base/5/5f/LoremIpsum.djvu"
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
// No helpful SVG file to copy, so make one ourselves
|
|
|
|
|
$data = '<?xml version="1.0" encoding="utf-8"?>' .
|
2014-03-18 17:00:11 +00:00
|
|
|
'<svg xmlns="http://www.w3.org/2000/svg"' .
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
' version="1.1" width="240" height="180"/>';
|
2012-01-09 22:33:00 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$backend->prepare( [ 'dir' => "$base/f/ff" ] );
|
|
|
|
|
$backend->quickCreate( [
|
|
|
|
|
'content' => $data, 'dst' => "$base/f/ff/Foobar.svg"
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
return function () use ( $backend ) {
|
|
|
|
|
if ( $backend instanceof MockFileBackend ) {
|
|
|
|
|
// In memory backend, so dont bother cleaning them up.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$this->teardownUploadBackend();
|
|
|
|
|
};
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove the dummy uploads directory
|
|
|
|
|
*/
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
private function teardownUploadBackend() {
|
2012-01-09 22:33:00 +00:00
|
|
|
if ( $this->keepUploads ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-08 21:47:14 +00:00
|
|
|
$public = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
|
|
|
|
|
->getZonePath( 'public' );
|
2012-01-09 22:33:00 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$this->deleteFiles(
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
"$public/3/3a/Foobar.jpg",
|
|
|
|
|
"$public/e/ea/Thumb.png",
|
|
|
|
|
"$public/0/09/Bad.jpg",
|
|
|
|
|
"$public/5/5f/LoremIpsum.djvu",
|
|
|
|
|
"$public/f/ff/Foobar.svg",
|
|
|
|
|
"$public/0/00/Video.ogv",
|
|
|
|
|
"$public/4/41/Audio.oga",
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2012-01-09 22:33:00 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* Delete the specified files and their parent directories
|
|
|
|
|
* @param array $files File backend URIs mwstore://...
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
private function deleteFiles( $files ) {
|
|
|
|
|
// Delete the files
|
2020-03-08 21:47:14 +00:00
|
|
|
$backend = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()->getBackend();
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
foreach ( $files as $file ) {
|
2020-11-13 05:19:43 +00:00
|
|
|
$backend->quickDelete( [ 'src' => $file ], [ 'force' => 1 ] );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// Delete the parent directories
|
|
|
|
|
foreach ( $files as $file ) {
|
|
|
|
|
$tmp = FileBackend::parentStoragePath( $file );
|
|
|
|
|
while ( $tmp ) {
|
|
|
|
|
if ( !$backend->clean( [ 'dir' => $tmp ] )->isOK() ) {
|
|
|
|
|
break;
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$tmp = FileBackend::parentStoragePath( $tmp );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-18 17:56:15 +00:00
|
|
|
/**
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* Add articles to the test DB.
|
2013-12-18 17:56:15 +00:00
|
|
|
*
|
2020-12-21 22:30:52 +00:00
|
|
|
* @see staticSetup() for more information about setup/teardown
|
|
|
|
|
*
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTestArticle[] $articles Article info array from TestFileReader
|
2020-12-21 22:30:52 +00:00
|
|
|
* @param ?ScopedCallback $nextTeardown The next teardown object
|
|
|
|
|
* @return ScopedCallback The teardown object
|
2013-12-18 17:56:15 +00:00
|
|
|
*/
|
2020-12-21 22:30:52 +00:00
|
|
|
public function addArticles(
|
|
|
|
|
array $articles, ?ScopedCallback $nextTeardown = null
|
|
|
|
|
): ScopedCallback {
|
2020-12-23 18:52:12 +00:00
|
|
|
$this->checkSetupDone( 'setupDatabase' );
|
2020-12-21 22:30:52 +00:00
|
|
|
$this->checkSetupDone( 'staticSetup' );
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$setup = [];
|
|
|
|
|
$teardown = [];
|
|
|
|
|
|
|
|
|
|
// Be sure ParserTestRunner::addArticle has correct language set,
|
|
|
|
|
// so that system messages get into the right language cache
|
2019-08-26 12:24:37 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
if ( $services->getContentLanguage()->getCode() !== 'en' ) {
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$setup['wgLanguageCode'] = 'en';
|
2019-08-26 12:24:37 +00:00
|
|
|
$lang = $services->getLanguageFactory()->getLanguage( 'en' );
|
2021-02-06 19:40:52 +00:00
|
|
|
$setup[] = static function () use ( $lang ) {
|
2018-07-25 14:37:16 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
$services->disableService( 'ContentLanguage' );
|
2021-02-07 13:10:36 +00:00
|
|
|
$services->redefineService( 'ContentLanguage', static function () use ( $lang ) {
|
2018-07-25 14:37:16 +00:00
|
|
|
return $lang;
|
|
|
|
|
} );
|
|
|
|
|
};
|
2021-02-06 19:40:52 +00:00
|
|
|
$teardown[] = static function () {
|
2018-07-25 14:37:16 +00:00
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'ContentLanguage' );
|
|
|
|
|
};
|
2020-09-22 18:16:23 +00:00
|
|
|
$reset = function () {
|
|
|
|
|
$this->resetTitleServices();
|
|
|
|
|
};
|
|
|
|
|
$setup[] = $reset;
|
|
|
|
|
$teardown[] = $reset;
|
2013-12-18 17:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$teardown[] = $this->executeSetupSnippets( $setup );
|
2013-04-26 15:45:18 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
foreach ( $articles as $info ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
$this->addArticle( $info->title, $info->text, $info->filename, $info->lineNumStart );
|
2016-03-09 04:42:33 +00:00
|
|
|
}
|
2012-01-09 22:33:00 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// Wipe WANObjectCache process cache, which is invalidated by article insertion
|
|
|
|
|
// due to T144706
|
2019-07-03 12:17:16 +00:00
|
|
|
MediaWikiServices::getInstance()->getMainWANObjectCache()->clearProcessCache();
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2022-04-12 18:21:23 +00:00
|
|
|
// Reset the service so that any "MediaWiki:bad image list" articles
|
|
|
|
|
// added get fetched
|
|
|
|
|
$teardown[] = static function () {
|
|
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'BadFileLookup' );
|
|
|
|
|
};
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$this->executeSetupSnippets( $teardown );
|
2020-12-21 22:30:52 +00:00
|
|
|
|
|
|
|
|
return $this->createTeardownObject( [ function () use ( $articles ) {
|
|
|
|
|
$this->cleanupArticles( $articles );
|
|
|
|
|
} ], $nextTeardown );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-18 03:41:34 +00:00
|
|
|
/**
|
|
|
|
|
* Remove articles from the test DB. This prevents independent parser
|
|
|
|
|
* test files from having conflicts when they choose the same names
|
|
|
|
|
* for article or template test fixtures.
|
|
|
|
|
*
|
2022-05-20 20:42:25 +00:00
|
|
|
* @param ParserTestArticle[] $articles Article info array from TestFileReader
|
2020-08-18 03:41:34 +00:00
|
|
|
*/
|
|
|
|
|
public function cleanupArticles( $articles ) {
|
2020-12-23 18:52:12 +00:00
|
|
|
$this->checkSetupDone( 'setupDatabase' );
|
2020-12-21 22:30:52 +00:00
|
|
|
$this->checkSetupDone( 'staticSetup' );
|
2020-12-23 18:52:12 +00:00
|
|
|
$user = MediaWikiIntegrationTestCase::getTestSysop()->getUser();
|
2021-10-30 15:45:49 +00:00
|
|
|
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
|
|
|
|
|
$delPageFactory = MediaWikiServices::getInstance()->getDeletePageFactory();
|
2020-08-18 03:41:34 +00:00
|
|
|
foreach ( $articles as $info ) {
|
2022-05-20 20:42:25 +00:00
|
|
|
$name = self::chomp( $info->title );
|
2020-08-18 03:41:34 +00:00
|
|
|
$title = Title::newFromText( $name );
|
2021-10-30 15:45:49 +00:00
|
|
|
$page = $wikiPageFactory->newFromTitle( $title );
|
|
|
|
|
$delPageFactory->newDeletePage( $page, $user )->deleteUnsafe( 'cleaning up' );
|
2020-08-18 03:41:34 +00:00
|
|
|
}
|
2022-08-29 20:54:27 +00:00
|
|
|
|
|
|
|
|
// Clear the static cache that Title class maintains.
|
|
|
|
|
// This ensures that Parsoid test runs that follow legacy parser test runs
|
|
|
|
|
// don't reuse titles. This matters because it looks like legacy test run
|
|
|
|
|
// and Parsoid test run differ in the number of articles they create in the db.
|
|
|
|
|
// We need to investigate that separately, but given that they differ, titles
|
|
|
|
|
// will get different article and revision ids across test runs.
|
|
|
|
|
// While we could add this to resetTitleServices(), there is really
|
|
|
|
|
// no reason to clear this for every test. Sufficient to clear this
|
|
|
|
|
// once per test file.
|
|
|
|
|
Title::clearCaches();
|
2020-08-18 03:41:34 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-09 22:33:00 +00:00
|
|
|
/**
|
|
|
|
|
* Insert a temporary test article
|
2020-12-23 18:52:12 +00:00
|
|
|
*
|
|
|
|
|
* @see MediaWikiIntegrationTestCase::addCoreDBData()
|
|
|
|
|
* @todo Refactor to share more code w/ ::addCoreDBData() or ::editPage
|
|
|
|
|
*
|
2014-04-17 18:43:42 +00:00
|
|
|
* @param string $name The title, including any prefix
|
|
|
|
|
* @param string $text The article text
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* @param string $file The input file name
|
2014-12-24 13:49:20 +00:00
|
|
|
* @param int|string $line The input line number, for reporting errors
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* @throws MWException
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
private function addArticle( $name, $text, $file, $line ) {
|
2012-01-09 22:33:00 +00:00
|
|
|
$text = self::chomp( $text );
|
|
|
|
|
$name = self::chomp( $name );
|
|
|
|
|
|
|
|
|
|
$title = Title::newFromText( $name );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
wfDebug( __METHOD__ . ": adding $name" );
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2020-01-09 23:48:34 +00:00
|
|
|
if ( $title === null ) {
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
throw new MWException( "invalid title '$name' at $file:$line\n" );
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
2020-12-23 18:52:12 +00:00
|
|
|
$user = MediaWikiIntegrationTestCase::getTestSysop()->getUser();
|
|
|
|
|
|
2017-09-16 12:34:15 +00:00
|
|
|
$newContent = ContentHandler::makeContent( $text, $title );
|
|
|
|
|
|
2022-09-01 21:18:41 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
|
|
|
|
|
$page = $services->getWikiPageFactory()->newFromTitle( $title );
|
2021-09-26 18:52:30 +00:00
|
|
|
$page->loadPageData( WikiPage::READ_LATEST );
|
2012-01-09 22:33:00 +00:00
|
|
|
|
|
|
|
|
if ( $page->exists() ) {
|
2020-07-03 00:20:38 +00:00
|
|
|
$content = $page->getContent( RevisionRecord::RAW );
|
2017-09-16 12:34:15 +00:00
|
|
|
// Only reject the title, if the content/content model is different.
|
|
|
|
|
// This makes it easier to create Template:(( or Template:)) in different extensions
|
|
|
|
|
if ( $newContent->equals( $content ) ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
throw new MWException(
|
|
|
|
|
"duplicate article '$name' with different content at $file:$line\n"
|
|
|
|
|
);
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-20 02:03:48 +00:00
|
|
|
// Optionally use mock parser, to make debugging of actual parser tests simpler.
|
2016-10-06 05:41:15 +00:00
|
|
|
// But initialise the MessageCache clone first, don't let MessageCache
|
|
|
|
|
// get a reference to the mock object.
|
2018-07-20 02:03:48 +00:00
|
|
|
if ( $this->disableSaveParse ) {
|
2022-01-27 20:19:18 +00:00
|
|
|
$services->getMessageCache()->getParser();
|
2019-12-30 06:58:16 +00:00
|
|
|
$services->disableService( 'Parser' );
|
|
|
|
|
$services->disableService( 'ParserFactory' );
|
|
|
|
|
$services->redefineService(
|
|
|
|
|
'Parser',
|
|
|
|
|
static function () {
|
|
|
|
|
return new ParserTestMockParser;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
$restore = static function () {
|
|
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'Parser' );
|
|
|
|
|
MediaWikiServices::getInstance()->resetServiceForTesting( 'ParserFactory' );
|
|
|
|
|
};
|
2018-07-20 02:03:48 +00:00
|
|
|
} else {
|
|
|
|
|
$restore = false;
|
|
|
|
|
}
|
2022-05-20 20:42:25 +00:00
|
|
|
$status = null;
|
2017-09-11 10:58:13 +00:00
|
|
|
try {
|
2021-06-24 08:42:19 +00:00
|
|
|
$status = $page->doUserEditContent(
|
2017-09-16 12:34:15 +00:00
|
|
|
$newContent,
|
2021-06-24 08:42:19 +00:00
|
|
|
$user,
|
2017-09-11 10:58:13 +00:00
|
|
|
'',
|
2021-06-24 08:42:19 +00:00
|
|
|
EDIT_NEW | EDIT_SUPPRESS_RC | EDIT_INTERNAL
|
2017-09-11 10:58:13 +00:00
|
|
|
);
|
|
|
|
|
} finally {
|
2018-07-20 02:03:48 +00:00
|
|
|
if ( $restore ) {
|
|
|
|
|
$restore();
|
|
|
|
|
}
|
2017-09-11 10:58:13 +00:00
|
|
|
}
|
2016-10-06 05:41:15 +00:00
|
|
|
|
2016-09-14 00:22:44 +00:00
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
throw new MWException( $status->getWikiText( false, false, 'en' ) );
|
|
|
|
|
}
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2020-12-23 18:52:12 +00:00
|
|
|
// an edit always attempt to purge backlink links such as history
|
|
|
|
|
// pages. That is unnecessary.
|
2022-01-27 20:19:18 +00:00
|
|
|
$jobQueueGroup = $services->getJobQueueGroup();
|
|
|
|
|
$jobQueueGroup->get( 'htmlCacheUpdate' )->delete();
|
2020-12-23 18:52:12 +00:00
|
|
|
// WikiPages::doEditUpdates randomly adds RC purges
|
2022-01-27 20:19:18 +00:00
|
|
|
$jobQueueGroup->get( 'recentChangesUpdate' )->delete();
|
2020-12-23 18:52:12 +00:00
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
// The RepoGroup cache is invalidated by the creation of file redirects
|
2016-09-28 03:29:54 +00:00
|
|
|
if ( $title->inNamespace( NS_FILE ) ) {
|
2022-01-27 20:19:18 +00:00
|
|
|
$services->getRepoGroup()->clearCache( $title );
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
}
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* Check if a hook is installed
|
2012-01-09 22:33:00 +00:00
|
|
|
*
|
2014-04-17 18:43:42 +00:00
|
|
|
* @param string $name
|
|
|
|
|
* @return bool True if tag hook is present
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
|
|
|
|
public function requireHook( $name ) {
|
2019-04-11 13:36:15 +00:00
|
|
|
$parser = MediaWikiServices::getInstance()->getParser();
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2020-12-21 16:52:41 +00:00
|
|
|
if ( preg_match( '/^[Ee]xtension:(.*)$/', $name, $matches ) ) {
|
2020-07-15 18:29:55 +00:00
|
|
|
$extName = $matches[1];
|
|
|
|
|
if ( ExtensionRegistry::getInstance()->isLoaded( $extName ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
$this->recorder->warning( " Skipping this test suite because it requires the '$extName' " .
|
|
|
|
|
"extension, which isn't loaded." );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-18 22:07:33 +00:00
|
|
|
if ( in_array( $name, $parser->getTags(), true ) ) {
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
return true;
|
2012-01-09 22:33:00 +00:00
|
|
|
} else {
|
2020-12-16 23:50:51 +00:00
|
|
|
$this->recorder->warning( " Skipping this test suite because it requires the '$name' hook, " .
|
2020-07-15 18:29:55 +00:00
|
|
|
"which isn't provided by any loaded extension." );
|
2012-01-09 22:33:00 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* Check if a function hook is installed
|
2012-01-09 22:33:00 +00:00
|
|
|
*
|
2014-04-17 18:43:42 +00:00
|
|
|
* @param string $name
|
|
|
|
|
* @return bool True if function hook is present
|
2012-01-09 22:33:00 +00:00
|
|
|
*/
|
|
|
|
|
public function requireFunctionHook( $name ) {
|
2019-04-11 13:36:15 +00:00
|
|
|
$parser = MediaWikiServices::getInstance()->getParser();
|
2012-01-09 22:33:00 +00:00
|
|
|
|
2021-02-18 22:36:51 +00:00
|
|
|
if ( in_array( $name, $parser->getFunctionHooks(), true ) ) {
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
return true;
|
2012-01-09 22:33:00 +00:00
|
|
|
} else {
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
$this->recorder->warning( " This test suite requires the '$name' function " .
|
|
|
|
|
"hook extension, skipping." );
|
2012-01-09 22:33:00 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
/**
|
2017-07-07 01:02:47 +00:00
|
|
|
* Fake constant timestamp to make sure time-related parser
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
* functions give a persistent value.
|
2017-07-07 01:02:47 +00:00
|
|
|
*
|
Deprecate Parser implementation methods (will be private in next release)
The following public methods were renamed and made private; the old name
is hard-deprecated and calls the new renamed private method:
Parser::doMagicLinks() => handleMagicLinks()
Parser::doDoubleUnderscore() => handleMagicLinks()
Parser::doHeadings() => handleHeadings()
Parser::doAllQuotes() => handleAllQuotes()
Parser::replaceExternalLinks() => handleExternalLinks()
Parser::replaceInternalLinks() => handleInternalLinks()
Parser::replaceInternalLinks2() => handleInternalLinks2()
Parser::getVariableValue() => expandMagicVariable()
Parser::initialiseVariables() => initializeVariables()
Parser::formatHeadings() => finalizeHeadings()
Parser::test{Pst,Preprocess,Srvus}() => fuzzTest{Pst,Preprocess,Srvus}()
Additionally, the following methods are not used externally, but are
used outside the Parser class by core code. They have been marked
@internal:
Parser::doQuotes() (used by {{#displaytitle}}),
Parser::getExternalLink{Rel,Attribs}() (used by Linker),
Parser::normalizeLinkUrl() (used by Special:LinkSearch and elsewhere).
Parser::{brace,arg,extension}Substitution() (used by PPFrame)
Code search query:
https://codesearch.wmflabs.org/deployed/?q=do%28MagicLinks%7CDoubleUnderscore%7CHeadings%7CAllQuotes%29%7Creplace%28ExternalLinks%7CInternalLinks%28%7C2%29%29%7CgetVariableValue%7CinitialiseVariables%7CformatHeadings%7Ctest%28Pst%7CPreprocess%7CSrvus%29%7CdoQuotes%7CgetExternalLink%28Rel%7CAttribs%29%7CnormalizeLinkUrl%7C%28brace%2Carg%2Cextension%29Substitution&i=nope&files=&repos=
Bug: T236810
Change-Id: I19a43ffc5dcfdd2981b51079c33422c964acb076
2019-10-28 19:52:50 +00:00
|
|
|
* - Parser::expandMagicVariable (via ParserGetVariableValueTs hook)
|
2017-07-07 01:02:47 +00:00
|
|
|
* - Parser::preSaveTransform (via ParserOptions)
|
2020-01-09 23:38:41 +00:00
|
|
|
* @return int Fake constant timestamp.
|
Refactor parser tests
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
2016-09-08 01:25:22 +00:00
|
|
|
*/
|
2017-07-07 01:02:47 +00:00
|
|
|
private function getFakeTimestamp() {
|
|
|
|
|
// parsed as '1970-01-01T00:02:03Z'
|
|
|
|
|
return 123;
|
2012-01-09 22:33:00 +00:00
|
|
|
}
|
|
|
|
|
}
|