Page MenuHomePhabricator

Integrate a covers-validator into the library bootstrap
Closed, ResolvedPublic


We can use for our independent libraries that have traditional PHPUnit setups (unlike MediaWiki).

Event Timeline

Legoktm created this task.Jan 24 2018, 7:34 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 24 2018, 7:34 PM

Change 406071 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/tools/cookiecutter-library@master] Add ockcyp/covers-validator

@Legoktm Hm.. how does this relate to the MediaWikiCoversValidator trait we use in MediaWiki core. Would it make sense to use one or the other for both cases? E.g. we could publish it as a non-mediawiki specific library used in core and in libs. Or we could use the covers-validator lib in core as well.

They are just two different approaches that have different entrypoints. Underneath both are using the same method for determining whether a method is covered.

ockcyp/covers-validator runs externally, and requires having a sane PHPUnit entrypoint (suite.xml file) to be able to find the tests.
MediaWikiCoversValidator is a trait that runs along with the normal PHPUnit tests, and just requires being added to each test individually (usually through inheritance).

I initially tried to get ockcyp to work for MediaWiki, but ran into issues with our custom tests/phpunit/phpunit.php wrapper not playing nicely. Maybe if/when T90875: Convert tests/phpunit/phpunit.php entrypoint to plain PHPUnit with bootstrap file is done, we can use that tool instead.

MediaWikiCoversValidator is harder to use since you need to add the trait everywhere. In MediaWiki most tests cases extend from MediaWikiTestCase so it was pretty easy to do. For libraries that just use plain PHPUnit\Framework\TestCase I think using ockcyp will be easier overall.

I think we can probably librarize MediaWikiCoversValidator for other projects that have weird requirements like MediaWiki, but I don't think we should encourage its use in libraries that don't need it.

Krinkle moved this task from Untriaged to In Dev on the Librarization board.Jan 26 2018, 7:47 PM

Change 406071 merged by jenkins-bot:
[mediawiki/tools/cookiecutter-library@master] Add ockcyp/covers-validator

Krinkle closed this task as Resolved.Feb 2 2018, 10:50 PM
Krinkle assigned this task to Legoktm.
Krinkle triaged this task as Medium priority.
Krinkle removed a project: Patch-For-Review.