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.

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.