Tests for maintenance scripts might want to cover some situations that cause the script to fatal. Currently, this isn't possible because Maintenance::fatalError calls exit() and brings the suite down. I think a quick and effective solution might be to create a new error type, MaintenanceFatalError extends \Error. Then the exit() can be replaced with throwing this error, either always (but need to ensure this won't break anything), or only if MW_PHPUNIT_TEST is defined.
Description
Description
Details
Details
Related Changes in Gerrit:
| Subject | Repo | Branch | Lines +/- | |
|---|---|---|---|---|
| Throw exception from Maintenance::fatalError when in PHPUnit tests | mediawiki/core | master | +49 -1 |
| Status | Subtype | Assigned | Task | ||
|---|---|---|---|---|---|
| Resolved | Dreamy_Jazz | T371167 Improve test coverage for maintenance scripts in core | |||
| Resolved | Dreamy_Jazz | T272241 Maintenance::fatalError cannot be covered in tests |
Event Timeline
Comment Actions
See also T99268: RfC: Create a proper command-line runner for MediaWiki maintenance tasks (currently, there are quite a few things making maintenance scripts hard to test).
Comment Actions
Change #1059475 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):
[mediawiki/core@master] Throw exception from Maintenance::fatalError when in PHPUnit tests
Comment Actions
Change #1059475 merged by jenkins-bot:
[mediawiki/core@master] Throw exception from Maintenance::fatalError when in PHPUnit tests