Page MenuHomePhabricator

Migrate Parser and extension tests away from deprecated PHPUnit TestSuite subclassing
Open, Needs TriagePublic

Description

We currently use "dynamic" test suites for parser tests, as well as extension/skin tests (including unit tests after r937559). On a theoretical level, this is not ideal because the list of tests to execute cannot be determined immediately, but is generated dynamically after PHPUnit has finished its setup. In practice, these dynamic test suites make it impossible to use paratest (T50217), which is unable to split the tests across multiple processes. On top of that extending TestSuite is no longer possible in PHPUnit 10 (T328919).

Therefore, we need to find another way to generate these test lists dynamically.

  • Extension tests suite
  • Parser tests suite

Related Objects

Event Timeline

Krinkle renamed this task from Stop extending PHPUnit's TestSuite class to Migrate Parser tests away from deprecated PHPUnit TestSuite subclassing.Dec 14 2023, 10:59 PM
Krinkle moved this task from Inbox to PHPUnit on the MediaWiki-Core-Tests board.
Daimona renamed this task from Migrate Parser tests away from deprecated PHPUnit TestSuite subclassing to Migrate Parser and extension tests away from deprecated PHPUnit TestSuite subclassing.Jan 28 2024, 6:25 PM

I've updated the task title to clarify that, unfortunately, it's not only parser tests that subclass TestSuite, but also extension/skin tests...

Change 1005636 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] [POC] Introduce a CLI script to generate PHPUnit config

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

My current proposal is to introduce a new CLI script that loads LocalSettings, and then uses the list of loaded extensions to generate a local phpunit.xml file, which can then be used to run tests normally. I've implemented this in the above proof of concept. CC'ing @Krinkle, @pmiazga, @daniel since we discussed this earlier today, in case you'd like to take a look and provide feedback. If not, apologies and feel free to unsubscribe :)

I also realized that there are more dynamic suites in extensions. These also need to be migrated. If we choose the approach above (script to autogenerate PHPUnit config), we may allow extensions to hook into the script and add/change suites; however, this adds complexity. It would be better to use other solutions in extensions, if possible.

For extension/skin tests, I have updated my previous patch and marked it as ready for review. The approach is to add an extra "build" step to PHPUnit, so you would run composer phpunit:config before running the tests (and note that this is only necessary if the set of available extensions/test directories changes). The composer phpunit command also does that for you automatically. Then we have a new structure test to verify that the config is up-to-date.

That would leave parser tests as the only remaining usage of dynamic suites, now that Scribunto tests have been updated in T358394. However, I'm not familiar with parser tests and don't know what the best solution would be for them. I can provide help if needed, but I can't drive this change because I don't have the necessary context.

Change #1005636 merged by jenkins-bot:

[mediawiki/core@master] Introduce a CLI script to generate PHPUnit config

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

Change #1247681 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] phpunit: Merge `skins` suite into `extensions`

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

Change #1247681 merged by jenkins-bot:

[mediawiki/core@master] phpunit: Merge `skins` suite into `extensions`

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

CCing @cscott as the wizard for thorny Parser test runner issues.

Change #1247719 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] phpunit: Add check for local config in bootstrap.php

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

Change #1248112 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[integration/config@master] dockerfiles: [quibble-coverage] Use local PHPUnit config

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

Change #1248113 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[integration/config@master] jjb: Generate PHPUnit config before running tests

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

Change #1248119 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] Rename phpunit.xml.dist to phpunit.xml.template

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

Change #1248112 merged by jenkins-bot:

[integration/config@master] dockerfiles: [quibble-coverage] Use local PHPUnit config

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

Mentioned in SAL (#wikimedia-releng) [2026-03-05T00:04:36Z] <James_F> Docker: [quibble-coverage] Use local PHPUnit config, for T345481

Change #1247719 merged by jenkins-bot:

[mediawiki/core@master] phpunit: Add check for local config in bootstrap.php

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

Change #1248113 merged by jenkins-bot:

[integration/config@master] jjb: Generate PHPUnit config before running tests

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

Change #1248119 merged by jenkins-bot:

[mediawiki/core@master] Rename phpunit.xml.dist to phpunit.xml.template

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

Change #1248394 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/CirrusSearch@master] tests: Fix QueueingRemediatorTest requestId mismatch

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

Change #1248400 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[integration/quibble@master] commands: Run composer phpunit:config for parallel tests

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

Change #1248452 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/core@master] Generate local PHPUnit config before preparing parallel runs

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

Change #1248394 merged by jenkins-bot:

[mediawiki/extensions/CirrusSearch@master] tests: Fix QueueingRemediatorTest requestId mismatch

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

Change #1248452 merged by jenkins-bot:

[mediawiki/core@master] Generate local PHPUnit config before preparing parallel runs

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

Change #1248500 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[integration/config@master] jjb: Avoid `composer phpunit:config` invocation in non-MW repos

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

Change #1248500 merged by jenkins-bot:

[integration/config@master] jjb: Avoid `composer phpunit:config` invocation in non-MW repos

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

Change #1248400 abandoned by Hashar:

[integration/quibble@master] commands: Run composer phpunit:config for parallel tests

Reason:

Thank you!

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

I created a subtask, T422866: Migrate parser tests to new phpunit:config mechanism, for the parser test-related piece of this. CTT isn't likely to get to this before next quarter though.