Test runner: Extend WP_PHPUnit_Util_Getopt instead of PHPUnit_TextUI_Command to parse incoming options.
props wawco. fixes #26725. git-svn-id: https://develop.svn.wordpress.org/trunk@26871 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
329672c70d
commit
2105b8683d
@ -95,8 +95,8 @@ require dirname( __FILE__ ) . '/utils.php';
|
||||
/**
|
||||
* A child class of the PHP test runner.
|
||||
*
|
||||
* Not actually used as a runner. Rather, used to access the protected
|
||||
* longOptions property, to parse the arguments passed to the script.
|
||||
* Used to access the protected longOptions property, to parse the arguments
|
||||
* passed to the script.
|
||||
*
|
||||
* If it is determined that phpunit was called with a --group that corresponds
|
||||
* to an @ticket annotation (such as `phpunit --group 12345` for bugs marked
|
||||
@ -105,15 +105,29 @@ require dirname( __FILE__ ) . '/utils.php';
|
||||
* If WP_TESTS_FORCE_KNOWN_BUGS is already set in wp-tests-config.php, then
|
||||
* how you call phpunit has no effect.
|
||||
*/
|
||||
class WP_PHPUnit_TextUI_Command extends PHPUnit_TextUI_Command {
|
||||
class WP_PHPUnit_Util_Getopt extends PHPUnit_Util_Getopt {
|
||||
protected $longOptions = array(
|
||||
'exclude-group=',
|
||||
'group=',
|
||||
);
|
||||
function __construct( $argv ) {
|
||||
$options = PHPUnit_Util_Getopt::getopt(
|
||||
$argv,
|
||||
'd:c:hv',
|
||||
array_keys( $this->longOptions )
|
||||
);
|
||||
array_shift( $argv );
|
||||
$options = array();
|
||||
while ( list( $i, $arg ) = each( $argv ) ) {
|
||||
try {
|
||||
if ( strlen( $arg ) > 1 && $arg[0] === '-' && $arg[1] === '-' ) {
|
||||
PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv );
|
||||
}
|
||||
}
|
||||
catch ( PHPUnit_Framework_Exception $e ) {
|
||||
// Enforcing recognized arguments or correctly formed arguments is
|
||||
// not really the concern here.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$ajax_message = true;
|
||||
foreach ( $options[0] as $option ) {
|
||||
foreach ( $options as $option ) {
|
||||
switch ( $option[0] ) {
|
||||
case '--exclude-group' :
|
||||
$ajax_message = false;
|
||||
@ -121,15 +135,17 @@ class WP_PHPUnit_TextUI_Command extends PHPUnit_TextUI_Command {
|
||||
case '--group' :
|
||||
$groups = explode( ',', $option[1] );
|
||||
foreach ( $groups as $group ) {
|
||||
if ( is_numeric( $group ) || preg_match( '/^(UT|Plugin)\d+$/', $group ) )
|
||||
if ( is_numeric( $group ) || preg_match( '/^(UT|Plugin)\d+$/', $group ) ) {
|
||||
WP_UnitTestCase::forceTicket( $group );
|
||||
}
|
||||
}
|
||||
$ajax_message = ! in_array( 'ajax', $groups );
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
if ( $ajax_message )
|
||||
if ( $ajax_message ) {
|
||||
echo "Not running ajax tests... To execute these, use --group ajax." . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
new WP_PHPUnit_TextUI_Command( $_SERVER['argv'] );
|
||||
new WP_PHPUnit_Util_Getopt( $_SERVER['argv'] );
|
||||
|
Loading…
Reference in New Issue
Block a user