mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-65435 behat: Support any arg type with behat reruns
Right now, when executing a single rerun of a parallel run using vendor/bin/behat, not all the argument alternatives are supported (equal or space). This commit allows both to work.
This commit is contained in:
parent
2018f4ebc1
commit
ddaae81510
@ -461,26 +461,40 @@ function behat_get_run_process() {
|
||||
}
|
||||
}
|
||||
} else if (defined('BEHAT_TEST') || defined('BEHAT_UTIL')) {
|
||||
if ($match = preg_filter('#--run=(.+)#', '$1', $argv)) {
|
||||
$behatrunprocess = reset($match);
|
||||
} else if ($k = array_search('--config', $argv)) {
|
||||
$behatconfig = str_replace("\\", "/", $argv[$k + 1]);
|
||||
// Try get it from config if present.
|
||||
if (!empty($CFG->behat_parallel_run)) {
|
||||
foreach ($CFG->behat_parallel_run as $run => $parallelconfig) {
|
||||
if (!empty($parallelconfig['behat_dataroot']) &&
|
||||
$parallelconfig['behat_dataroot'] . '/behat/behat.yml' == $behatconfig) {
|
||||
$behatconfig = '';
|
||||
|
||||
$behatrunprocess = $run + 1; // We start process from 1.
|
||||
break;
|
||||
if ($match = preg_filter('#--run=(.+)#', '$1', $argv)) {
|
||||
// Try to guess the run from the existence of the --run arg.
|
||||
$behatrunprocess = reset($match);
|
||||
|
||||
} else {
|
||||
// Try to guess the run from the existence of the --config arg. Note there are 2 alternatives below.
|
||||
if ($k = array_search('--config', $argv)) {
|
||||
// Alternative 1: --config /path/to/config.yml => (next arg, pick it).
|
||||
$behatconfig = str_replace("\\", "/", $argv[$k + 1]);
|
||||
|
||||
} else if ($config = preg_filter('#^(?:--config[ =]*)(.+)$#', '$1', $argv)) {
|
||||
// Alternative 2: --config=/path/to/config.yml => (same arg, just get the path part).
|
||||
$behatconfig = str_replace("\\", "/", reset($config));
|
||||
}
|
||||
|
||||
// Try get it from config if present.
|
||||
if ($behatconfig) {
|
||||
if (!empty($CFG->behat_parallel_run)) {
|
||||
foreach ($CFG->behat_parallel_run as $run => $parallelconfig) {
|
||||
if (!empty($parallelconfig['behat_dataroot']) &&
|
||||
$parallelconfig['behat_dataroot'] . '/behat/behat.yml' == $behatconfig) {
|
||||
$behatrunprocess = $run + 1; // We start process from 1.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check if default behat datroot increment was done.
|
||||
if (empty($behatrunprocess)) {
|
||||
$behatdataroot = str_replace("\\", "/", $CFG->behat_dataroot . '/' . BEHAT_PARALLEL_SITE_NAME);
|
||||
$behatrunprocess = preg_filter("#^{$behatdataroot}" . "(.+?)[/|\\\]behat[/|\\\]behat\.yml#", '$1',
|
||||
$behatconfig);
|
||||
// Check if default behat dataroot increment was done.
|
||||
if (empty($behatrunprocess)) {
|
||||
$behatdataroot = str_replace("\\", "/", $CFG->behat_dataroot . '/' . BEHAT_PARALLEL_SITE_NAME);
|
||||
$behatrunprocess = preg_filter("#^{$behatdataroot}" . "(.+?)[/|\\\]behat[/|\\\]behat\.yml#", '$1',
|
||||
$behatconfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user