phpunit: Remove custom MediaWikiPHPUnitCommand and use default directly
Move the relevant options to the config file instead, and add some hacky code to force that config file if none was passed. "--help" works even without the previous hack. Bug: T90875 Change-Id: I84421e3eeaad0f88be83477cb99d6524abe13b77
This commit is contained in:
parent
cffc40d37e
commit
204776e42c
6 changed files with 16 additions and 36 deletions
|
|
@ -158,7 +158,7 @@
|
|||
"phpunit:integration": "phpunit --colors=always --testsuite=core:integration,extensions:integration,skins:integration",
|
||||
"phpunit:coverage": "phpunit --testsuite=core:unit --exclude-group Dump,Broken",
|
||||
"phpunit:coverage-edit": "ComposerPhpunitXmlCoverageEdit::onEvent",
|
||||
"phpunit:entrypoint": "php tests/phpunit/phpunit.php"
|
||||
"phpunit:entrypoint": "php tests/phpunit/phpunit.php -c tests/phpunit/suite.xml"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ $wgAutoloadClasses += [
|
|||
'MediaWikiGroupValidator' => "$testDir/phpunit/MediaWikiGroupValidator.php",
|
||||
'MediaWikiLangTestCase' => "$testDir/phpunit/MediaWikiLangTestCase.php",
|
||||
'MediaWikiLoggerPHPUnitExtension' => "$testDir/phpunit/MediaWikiLoggerPHPUnitExtension.php",
|
||||
'MediaWikiPHPUnitCommand' => "$testDir/phpunit/MediaWikiPHPUnitCommand.php",
|
||||
'MediaWikiPHPUnitResultPrinter' => "$testDir/phpunit/MediaWikiPHPUnitResultPrinter.php",
|
||||
'MediaWikiTestCaseTrait' => "$testDir/phpunit/MediaWikiTestCaseTrait.php",
|
||||
'MediaWikiUnitTestCase' => "$testDir/phpunit/MediaWikiUnitTestCase.php",
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
use PHPUnit\TextUI\Command;
|
||||
|
||||
class MediaWikiPHPUnitCommand extends Command {
|
||||
protected function handleCustomTestSuite(): void {
|
||||
// Use our suite.xml
|
||||
if ( !isset( $this->arguments['configuration'] ) ) {
|
||||
$this->arguments['configuration'] = __DIR__ . '/suite.xml';
|
||||
}
|
||||
|
||||
// Output only to stderr to avoid "Headers already sent" problems
|
||||
$this->arguments['stderr'] = true;
|
||||
|
||||
// Use a custom result printer that includes per-test logging output
|
||||
// when nothing is provided.
|
||||
if ( !isset( $this->arguments['printer'] ) ) {
|
||||
$this->arguments['printer'] = MediaWikiPHPUnitResultPrinter::class;
|
||||
}
|
||||
}
|
||||
|
||||
public function publicShowHelp() {
|
||||
parent::showHelp();
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ EOF;
|
|||
|
||||
// The TestRunner class will run each test suite and may call
|
||||
// exit() with an exit status code. As such, we cannot run code "after the last test"
|
||||
// by adding statements to PHPUnitMaintClass::execute or MediaWikiPHPUnitCommand::run.
|
||||
// by adding statements to PHPUnitMaintClass::execute.
|
||||
// Instead, we work around it by registering a shutdown callback from the bootstrap
|
||||
// file, which runs before PHPUnit starts.
|
||||
// @todo Once we use PHPUnit 8 or higher, use the 'AfterLastTestHook' feature.
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use PHPUnit\TextUI\Command;
|
||||
|
||||
class PHPUnitMaintClass {
|
||||
public function setup() {
|
||||
|
|
@ -136,8 +137,15 @@ class PHPUnitMaintClass {
|
|||
|
||||
MediaWikiCliOptions::initialize();
|
||||
|
||||
$command = new MediaWikiPHPUnitCommand();
|
||||
$command->run( $_SERVER['argv'], true );
|
||||
$command = new Command();
|
||||
$args = $_SERVER['argv'];
|
||||
$hasConfigOpt = (bool)getopt( 'c:', [ 'configuration:' ] );
|
||||
if ( !$hasConfigOpt ) {
|
||||
// XXX HAX: Use our default file. This is a temporary hack, to be removed when this file goes away
|
||||
// or when T227900 is resolved.
|
||||
$args[] = '--configuration=' . __DIR__ . '/suite.xml';
|
||||
}
|
||||
$command->run( $args, true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -193,9 +201,4 @@ define( 'MW_SETUP_CALLBACK', 'wfPHPUnitSetup' );
|
|||
|
||||
require_once "$IP/includes/Setup.php";
|
||||
|
||||
if ( in_array( '--help', $argv, true ) ) {
|
||||
$command = new MediaWikiPHPUnitCommand();
|
||||
$command->publicShowHelp();
|
||||
die( 1 );
|
||||
}
|
||||
$wrapper->execute();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@
|
|||
failOnRisky="true"
|
||||
beStrictAboutTestsThatDoNotTestAnything="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
verbose="false">
|
||||
verbose="false"
|
||||
printerClass="MediaWikiPHPUnitResultPrinter"
|
||||
stderr="true">
|
||||
<!-- Output only to stderr to avoid "Headers already sent" problems -->
|
||||
<testsuites>
|
||||
<testsuite name="includes">
|
||||
<directory>includes</directory>
|
||||
|
|
|
|||
Loading…
Reference in a new issue