Skip to content

Commit

Permalink
Merge branch 'MDL-65435_36' of git://github.com/stronk7/moodle into M…
Browse files Browse the repository at this point in the history
…OODLE_36_STABLE
  • Loading branch information
andrewnicols committed May 9, 2019
2 parents 5d9bf8f + 42481b9 commit 6be75c4
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions lib/behat/lib.php
Expand Up @@ -461,26 +461,40 @@ function behat_get_run_process() {
}
}
} else if (defined('BEHAT_TEST') || defined('BEHAT_UTIL')) {
$behatconfig = '';

if ($match = preg_filter('#--run=(.+)#', '$1', $argv)) {
// Try to guess the run from the existence of the --run arg.
$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) {

$behatrunprocess = $run + 1; // We start process from 1.
break;
} 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);
}
}
}
}
Expand Down

0 comments on commit 6be75c4

Please sign in to comment.