mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-77733 behat: Remove extraneous no-axe option
There is no need for no-axe if we make axe a boolean value. We already have automatic support for negated boolean flags.
This commit is contained in:
parent
096f1e67c8
commit
5e32d574c6
@ -49,8 +49,7 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'torun' => 0,
|
||||
'optimize-runs' => '',
|
||||
'add-core-features-to-theme' => false,
|
||||
'axe' => '',
|
||||
'no-axe' => false,
|
||||
'axe' => null,
|
||||
'disable-composer' => false,
|
||||
'composer-upgrade' => true,
|
||||
'composer-self-update' => true,
|
||||
@ -111,11 +110,9 @@ if (!empty($options['help'])) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!empty($options['axe'])) {
|
||||
if ($options['axe']) {
|
||||
echo "Axe accessibility tests are enabled by default, to disable them, use the --no-axe option.\n";
|
||||
}
|
||||
|
||||
if (!empty($options['no-axe'])) {
|
||||
} else if ($options['axe'] === false) {
|
||||
echo "Axe accessibility tests have been disabled.\n";
|
||||
}
|
||||
|
||||
@ -127,22 +124,17 @@ if ($options['parallel'] && $options['parallel'] > 1) {
|
||||
$utilfile = 'util.php';
|
||||
// Sanitize all input options, so they can be passed to util.
|
||||
foreach ($options as $option => $value) {
|
||||
if ($value) {
|
||||
$commandoptions .= " --$option=\"$value\"";
|
||||
}
|
||||
$commandoptions .= behat_get_command_flags($option, $value);
|
||||
}
|
||||
} else {
|
||||
// Only sanitize options for single run.
|
||||
$cmdoptionsforsinglerun = [
|
||||
'add-core-features-to-theme',
|
||||
'axe',
|
||||
'no-axe',
|
||||
];
|
||||
|
||||
foreach ($cmdoptionsforsinglerun as $option) {
|
||||
if (!empty($options[$option])) {
|
||||
$commandoptions .= " --$option='$options[$option]'";
|
||||
}
|
||||
$commandoptions .= behat_get_command_flags($option, $options[$option]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,7 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'torun' => 0,
|
||||
'optimize-runs' => '',
|
||||
'add-core-features-to-theme' => false,
|
||||
'axe' => '',
|
||||
'no-axe' => false,
|
||||
'axe' => true,
|
||||
),
|
||||
array(
|
||||
'h' => 'help',
|
||||
@ -321,12 +320,7 @@ function commands_to_execute($options) {
|
||||
}
|
||||
|
||||
foreach ($extraoptions as $option => $value) {
|
||||
if ($options[$option]) {
|
||||
$extra .= " --$option";
|
||||
if ($value) {
|
||||
$extra .= "=\"$value\"";
|
||||
}
|
||||
}
|
||||
$extra .= behat_get_command_flags($option, $value);
|
||||
}
|
||||
|
||||
if (empty($options['parallel'])) {
|
||||
|
@ -52,8 +52,7 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'updatesteps' => false,
|
||||
'optimize-runs' => '',
|
||||
'add-core-features-to-theme' => false,
|
||||
'axe' => '',
|
||||
'no-axe' => false,
|
||||
'axe' => true,
|
||||
),
|
||||
array(
|
||||
'h' => 'help',
|
||||
@ -187,11 +186,8 @@ if ($options['install']) {
|
||||
behat_config_manager::set_behat_run_config_value('behatsiteenabled', 1);
|
||||
}
|
||||
|
||||
// Always run Behat with axe tests.
|
||||
if (!$options['no-axe']) {
|
||||
behat_config_manager::set_behat_run_config_value('axe', true);
|
||||
}
|
||||
|
||||
// Configure axe according to option.
|
||||
behat_config_manager::set_behat_run_config_value('axe', $options['axe']);
|
||||
|
||||
// Enable test mode.
|
||||
$timestart = microtime(true);
|
||||
|
@ -563,3 +563,24 @@ function cli_execute_parallel($cmds, $cwd = null, $delay = 0) {
|
||||
}
|
||||
return $processes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get command flags for an option/value combination
|
||||
*
|
||||
* @param string $option
|
||||
* @param string|bool|null $value
|
||||
* @return string
|
||||
*/
|
||||
function behat_get_command_flags(string $option, $value): string {
|
||||
$commandoptions = '';
|
||||
if (is_bool($value)) {
|
||||
if ($value) {
|
||||
return " --{$option}";
|
||||
} else {
|
||||
return " --no-{$option}";
|
||||
}
|
||||
} else if ($value !== null) {
|
||||
return " --$option=\"$value\"";
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user