Starting point. I found the following documentation to generate extension code coverage
in addition, I extracted that configuration from Jenkins
https://www.mediawiki.org/wiki/MediaWiki-Docker/Extension/Math#Code_coverage_report
which required MediaWiki-docker, which I would like to avoid, as running things locally feels more instant and reliable.
Q1 Is that even a good idea, or is everyone using mw-docker?
When trying to generate code-coverage reports locally, I ran into the following issues:
- It took too long (I got a new computer)
- I did need to set XDEBUG_MODE=coverage(It was not difficult to figure out, but could be added to the documentation.)
- I added the following lines to suite.xml (almost as documented, not too difficult, but it makes the mw-core git repo dirty and harder to upgrade)
diff --git a/tests/phpunit/suite.xml b/tests/phpunit/suite.xml index 85ed3369166..71b618ee946 100644 --- a/tests/phpunit/suite.xml +++ b/tests/phpunit/suite.xml @@ -72,6 +72,7 @@ This configuration file has been deprecated in favour of phpunit.xml.dist. <include> <directory suffix=".php">../../includes</directory> <directory suffix=".php">../../maintenance</directory> + <directory suffix=".php">../../extensions/Math/src</directory>
- The database tear-down failed as the service container had no configuration settings. I was unable to solve it and ignored the problem
diff --git a/tests/phpunit/MediaWikiIntegrationTestCase.php b/tests/phpunit/MediaWikiIntegrationTestCase.php index 05873a58ba2..f40dd6ec955 100644 --- a/tests/phpunit/MediaWikiIntegrationTestCase.php +++ b/tests/phpunit/MediaWikiIntegrationTestCase.php @@ -1704,13 +1704,17 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { $services = MediaWikiServices::getInstance(); ( new HookRunner( $services->getHookContainer() ) )->onUnitTestsBeforeDatabaseTeardown(); - - $jobQueueGroup = $services->getJobQueueGroup(); - foreach ( $wgJobClasses as $type => $class ) { - // Delete any jobs under the clone DB (or old prefix in other stores) - $jobQueueGroup->get( $type )->delete(); + try{ + $jobQueueGroup = $services->getJobQueueGroup(); + foreach ( $wgJobClasses as $type => $class ) { + // Delete any jobs under the clone DB (or old prefix in other stores) + $jobQueueGroup->get( $type )->delete(); + } + } catch (Exception $e) { + // Ignore exceptions from the job queue, as they are not critical } + if ( self::$dbClone ) {
without that, I see the following output (and no coverage report)
... 2138 / 2138 (100%)PHP Fatal error: Uncaught InvalidArgumentException: Key "JobTypeConf" not found in input sources in /Users/physikerwelt/git/mw/includes/config/ServiceOptions.php:60
Stack trace:
#0 /Users/physikerwelt/git/mw/includes/ServiceWiring.php(1049): MediaWiki\Config\ServiceOptions->__construct(Array, Object(MediaWiki\Config\GlobalVarConfig))
#1 /Users/physikerwelt/git/mw/vendor/wikimedia/services/src/ServiceContainer.php(445): Wikimedia\Services\ServiceContainer::{closure}(Object(MediaWiki\MediaWikiServices))
#2 /Users/physikerwelt/git/mw/vendor/wikimedia/services/src/ServiceContainer.php(411): Wikimedia\Services\ServiceContainer->createService('JobQueueGroupFa...')
#3 /Users/physikerwelt/git/mw/includes/MediaWikiServices.php(357): Wikimedia\Services\ServiceContainer->getService('JobQueueGroupFa...')
#4 /Users/physikerwelt/git/mw/includes/MediaWikiServices.php(1251): MediaWiki\MediaWikiServices->getService('JobQueueGroupFa...')
#5 /Users/physikerwelt/git/mw/includes/ServiceWiring.php(1044): MediaWiki\MediaWikiServices->getJobQueueGroupFactory()
#6 /Users/physikerwelt/git/mw/vendor/wikimedia/services/src/ServiceContainer.php(445): Wikimedia\Services\ServiceContainer::{closure}(Object(MediaWiki\MediaWikiServices))
#7 /Users/physikerwelt/git/mw/vendor/wikimedia/services/src/ServiceContainer.php(411): Wikimedia\Services\ServiceContainer->createService('JobQueueGroup')
#8 /Users/physikerwelt/git/mw/includes/MediaWikiServices.php(357): Wikimedia\Services\ServiceContainer->getService('JobQueueGroup')
#9 /Users/physikerwelt/git/mw/includes/MediaWikiServices.php(1244): MediaWiki\MediaWikiServices->getService('JobQueueGroup')
#10 /Users/physikerwelt/git/mw/tests/phpunit/MediaWikiIntegrationTestCase.php(1707): MediaWiki\MediaWikiServices->getJobQueueGroup()
#11 /Users/physikerwelt/git/mw/tests/phpunit/bootstrap.maintenance.php(28): MediaWikiIntegrationTestCase::teardownTestDB()
#12 [internal function]: PHPUnit\Util\FileLoader::{closure}()
#13 {main}
thrown in /Users/physikerwelt/git/mw/includes/config/ServiceOptions.php on line 60
Fatal error: Uncaught InvalidArgumentException: Key "JobTypeConf" not found in input sources in /Users/physikerwelt/git/mw/includes/config/ServiceOptions.php:60
Stack trace:
#0 /Users/physikerwelt/git/mw/includes/ServiceWiring.php(1049): MediaWiki\Config\ServiceOptions->__construct(Array, Object(MediaWiki\Config\GlobalVarConfig))
#1 /Users/physikerwelt/git/mw/vendor/wikimedia/services/src/ServiceContainer.php(445): Wikimedia\Services\ServiceContainer::{closure}(Object(MediaWiki\MediaWikiServices))
#2 /Users/physikerwelt/git/mw/vendor/wikimedia/services/src/ServiceContainer.php(411): Wikimedia\Services\ServiceContainer->createService('JobQueueGroupFa...')
#3 /Users/physikerwelt/git/mw/includes/MediaWikiServices.php(357): Wikimedia\Services\ServiceContainer->getService('JobQueueGroupFa...')
#4 /Users/physikerwelt/git/mw/includes/MediaWikiServices.php(1251): MediaWiki\MediaWikiServices->getService('JobQueueGroupFa...')
#5 /Users/physikerwelt/git/mw/includes/ServiceWiring.php(1044): MediaWiki\MediaWikiServices->getJobQueueGroupFactory()
#6 /Users/physikerwelt/git/mw/vendor/wikimedia/services/src/ServiceContainer.php(445): Wikimedia\Services\ServiceContainer::{closure}(Object(MediaWiki\MediaWikiServices))
#7 /Users/physikerwelt/git/mw/vendor/wikimedia/services/src/ServiceContainer.php(411): Wikimedia\Services\ServiceContainer->createService('JobQueueGroup')
#8 /Users/physikerwelt/git/mw/includes/MediaWikiServices.php(357): Wikimedia\Services\ServiceContainer->getService('JobQueueGroup')
#9 /Users/physikerwelt/git/mw/includes/MediaWikiServices.php(1244): MediaWiki\MediaWikiServices->getService('JobQueueGroup')
#10 /Users/physikerwelt/git/mw/tests/phpunit/MediaWikiIntegrationTestCase.php(1707): MediaWiki\MediaWikiServices->getJobQueueGroup()
#11 /Users/physikerwelt/git/mw/tests/phpunit/bootstrap.maintenance.php(28): MediaWikiIntegrationTestCase::teardownTestDB()
#12 [internal function]: PHPUnit\Util\FileLoader::{closure}()
#13 {main}
thrown in /Users/physikerwelt/git/mw/includes/config/ServiceOptions.php on line 60
You should really speed up these slow tests (>50ms)...
1. 1005ms to run MediaWiki\\Extension\\Math\\Tests\\WikiTexVC\\AllTest::testRunCases with data set "Big"
2. 478ms to run MediaWiki\\Extension\\Math\\Tests\\PreferencesIntegrationTest::testMathOptionRegistered
3. 219ms to run MediaWiki\\Extension\\Math\\Tests\\WikiTexVC\\AllTest::testRunCases with data set "Literals (1)"
4. 194ms to run MediaWiki\\Extension\\Math\\Tests\\WikiTexVC\\AllTest::testRunCases with data set "FUN_AR1"
5. 145ms to run MediaWiki\\Extension\\Math\\Tests\\PreferencesIntegrationTest::testInvalidDefaultOptionFixed
6. 141ms to run MediaWiki\\Extension\\Math\\Tests\\WikiTexVC\\AllTest::testRunCases with data set "Literals (3)"
7. 122ms to run phpunit\\InputCheck\\InputCheckFactoryTest::testNewMathoidChecker
8. 116ms to run MediaWiki\\Extension\\Math\\Tests\\WikiTexVC\\AllTest::testRunCases with data set "Matrices"
9. 82ms to run MediaWiki\\Extension\\Math\\Tests\\WikiTexVC\\AllTest::testRunCases with data set "Delimiters (4)"
10. 76ms to run MediaWiki\\Extension\\Math\\InputCheck\\LocalCheckerTest::testInvalid
...and there are 5 more above your threshold hidden from view
Key "JobTypeConf" not found in input sourcesI'm not sure what the real reason for the error is. Maybe the Math extension runs database tests without properly using the desired interfaces, or I'm running the tests in the wrong way.