Commit graph

17 commits

Author SHA1 Message Date
Umherirrender
a3a9cf99cb tests: Use namespaced class names in @covers annotations
Assist from 8c9cb701e56226cac43fee2fa24b0d0e586f1733

Change-Id: I47897c499028d9e24c00ad0bc6ba7fd8002d9bc1
2024-01-27 01:11:07 +01:00
James D. Forrester
468e69bccc Namespace Sanitizer under \MediaWiki\Parser
Bug: T166010
Change-Id: Id13dcbf7a0372017495958dbc4f601f40c122508
2023-09-21 05:39:23 +00:00
C. Scott Ananian
5a49745add tests/parser/TestMode: move parser test helper class to parsoid library
Depends-On: I6a653889afd42fefb61daefd8ac842107dce8759
Depends-On: I73f320dfb03e5c26971a7bc36564021d2c9f3695
Change-Id: Id3e44a5b419d7f6917819e72c046f94a3a2286fe
2022-08-16 16:26:25 -04:00
Máté Szabó
85017a30b2 phpunit: Fix trivial dynamic property usages in tests
Dynamic property creation is deprecated in PHP 8.2 (E_DEPRECATED).
Migrate some trivial cases in tests to use explicitly declared fields
instead, and remove the unused lastLog field from
MediaWikiLoggerPHPUnitExtension.

Notably this does not yet address MediaWikiIntegrationTestCase using
dynamic properties to associate ephemeral data with DB connections used
for tests.

Bug: T314099
Change-Id: I55453c0d254012b69c6843c54cfa8345fa5744fa
2022-07-29 01:59:23 +02:00
C. Scott Ananian
a5a04f56bd Pass <Test,TestMode> as argument pair, deprecate old TestFileReader
We introduced a new type for "ParserTestMode" and then uniformly pass
this around alongside the ParserTest object itself.  (We started by
using a string for the $mode but the "explicit changetree" mode
requires more structured data.  We *could* encode this in JSON just to
keep the string type around, but it seems cleaner and more future
proof to wrap this in a proper class type.)

Removed the old TestFileReader wrapper class, which served only as
a thunk to convert the new Test class into the same sort of array
which the legacy parser test runner code expected.  There's still
some remaining ::testToArray() usage here for the TestRecorder
framework, but that will be cleaned up in a future patch.

Also updated the TestRecorder with stronger types: use the same
<Test,TestMode> pair when invoking the TestRecorder, instead of the
loosely typed array we'd used previously.

Change-Id: Iec4c0c7972a655b4faccacc67bdc3ca66d4c163d
2022-06-03 17:15:38 -04:00
Subramanya Sastry
b5bcc0dec3 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-05-20 16:23:16 -04:00
Subramanya Sastry
3c59432f2d Refactor Parsoid test runner to simplify testing non-wt2html modes
* This creates a fresh PHPUnit test for every test mode of a test.
  Parsoid's native test runner does this a lot more efficiently by
  reusing pipelines, env objects, and also intermediate test results.

  That way of running tests is trickier in the PHPUnit test setup.

* Non-wt2html test modes will come in future patches.

Bug: T270311
Depends-On: Iacdff9e47e0d98ac3aa3a61757935d6ea3e91096
Change-Id: I58f63ebd53939b358cefe60ac34f26cded52697d
2022-04-06 00:48:35 +05:30
Thiemo Kreuz
6805f39a30 Remove unused default values from class properties
In all these cases the property is unconditionally set in
the constructor. The extra initialisation is effectively
dead code and an extra source of errors and confusion.

Change-Id: Icae13390d5ca5c14e2754f3be4eb956dd7f54ac4
2021-05-12 13:44:28 +02:00
C. Scott Ananian
71aa8e0e0d Add support for running parsertests with Parsoid in integrated mode
This allows us to move Parsoid-specific extension code from the
Parsoid repo into the extension's own repository and still have
Parsoid parser tests run on it via core's mechanism for running
extension tests.

Factored out some common ParserOptions setup into a common helper
function.  There are a number of features still missing from the
Parsoid test runner, which are marked with @todo comments and
phab task numbers.

Bug: T254181
Change-Id: Ifaf53862b96e9127d8f375ad8dd0cc362cba9f5b
2020-12-23 15:50:50 -05:00
C. Scott Ananian
3bf9a8e577 ParserTestFileSuite: run staticSetup once per suite
We now run staticSetup once per suite, instead of once per test.  This
matches the way that parserTests.php runs the tests, and speeds up
testing.  In addition, it allows simplifying a bit of redundant code
in ParserTestRunner::addArticles() because we know that static setup
has been done.

Change-Id: Id93412cf9eb714af693aa130de1b02c4ef87d6e0
2020-12-23 15:50:50 -05:00
Thiemo Kreuz
5f3a92385b Fix visibility of setUp/tearDown
Change-Id: I636be48eb9f713680abac35d46091f7b49374696
2020-06-16 21:02:05 +02:00
Nikki Nikkhoui
4a7a03f5d6 Hide deprecated warnings for Hooks::clear()
Some tests were failing after Hooks::clear() was deprecated in
the new HookContainer.php, and needed to have the deprecation
warning hidden to pass.

Bug: T250102
Change-Id: I59784e7972517488ba4cb8d0bad8d09a6f534f48
2020-04-14 19:28:50 +00:00
Umherirrender
e0949ceef0 Fix skipping of parser test suites
Parser tests using 'requirements' in the parser test file was running,
when there should be skipped.

Follow-Up: Ia12658554c94497a204b7f65f1a6f7b1fa0310ac
Change-Id: I12ff5b4f3a194a39b69a6773eb074ad58a8c9e00
2020-03-20 15:26:14 +01:00
C. Scott Ananian
5cbb64f56a 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-25 11:22:45 -05:00
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00
Thiemo Kreuz
8a4e15db7f Add missing newline between <?php and namespace/use section
The rest of the codebase is using this code formatting standard.

Change-Id: I4d2ba61757a7e28d40096d9dc5915005c340d4f2
2019-06-03 13:36:48 +00:00
Aryeh Gregor
2bb3551082 Only use "*Test.php" for actual PHPUnit tests
Otherwise I get errors every time I try to run PHPUnit on includes/ or
includes/parser, because it tries to run ParserIntegrationTest.php and
fails.  Apparently the <exclude> in suite.xml doesn't work if PHPUnit is
invoked on a directory.

Bug: T201278
Change-Id: I7d09576bee2705d8516152e8fa671da8dac40233
2018-10-03 20:22:22 +03:00
Renamed from tests/phpunit/includes/parser/ParserIntegrationTest.php (Browse further)