Show the PHPUnit help in phpunit.php --help

Split Maintenance::showHelp() from Maintenance::maybeHelp(), and
override it in phpunit.php. Expose PHPUnit's protected method
Command::showHelp() in our subclass and call it, so that running
"phpunit.php  --help" causes the MediaWiki options to be shown, followed
by the PHPUnit options.

Change-Id: I4687d484e322a465af0492789645819cd8a7b67c
This commit is contained in:
Tim Starling 2019-11-25 15:51:38 +11:00
parent 375acb6b46
commit 15e058d46e
3 changed files with 19 additions and 3 deletions

View file

@ -1060,14 +1060,22 @@ abstract class Maintenance {
}
/**
* Maybe show the help.
* Maybe show the help. If the help is shown, exit.
*
* @param bool $force Whether to force the help to show, default false
*/
protected function maybeHelp( $force = false ) {
if ( !$force && !$this->hasOption( 'help' ) ) {
return;
}
$this->showHelp();
die( 1 );
}
/**
* Definitely show the help. Does not exit.
*/
protected function showHelp() {
$screenWidth = 80; // TODO: Calculate this!
$tab = " ";
$descWidth = $screenWidth - ( 2 * strlen( $tab ) );
@ -1172,8 +1180,6 @@ abstract class Maintenance {
}
$this->output( "\n" );
}
die( 1 );
}
/**

View file

@ -22,4 +22,8 @@ class MediaWikiPHPUnitCommand extends Command {
$this->arguments['printer'] = MediaWikiPHPUnitResultPrinter::class;
}
}
public function publicShowHelp() {
parent::showHelp();
}
}

View file

@ -110,6 +110,12 @@ class PHPUnitMaintClass extends Maintenance {
$_SERVER['argv'] = $argv;
}
protected function showHelp() {
parent::showHelp();
$this->output( "PHPUnit options are also accepted:\n\n" );
$command = new MediaWikiPHPUnitCommand();
$command->publicShowHelp();
}
}
$maintClass = 'PHPUnitMaintClass';