MDL-55986 behat: Added option to optimize parallel runs by tags

run.php should only be used for running behat
before this patch if tags were passed, then behat.yml
was being re-written with features havings tags.
As this is not ideal, this option is now removed and
features with tags will be optimally split
by init.php when --optimize-run option is passed
This commit is contained in:
Rajesh Taneja
2016-10-03 15:38:04 +08:00
parent c2b0213b08
commit b04ca8c8a1
7 changed files with 135 additions and 198 deletions
-31
View File
@@ -55,7 +55,6 @@ list($options, $unrecognised) = cli_get_params(
'fromrun' => 1,
'torun' => 0,
'single-run' => false,
'run-with-theme' => false,
),
array(
'h' => 'help',
@@ -79,7 +78,6 @@ Options:
--replace Replace args string with run process number, useful for output.
--fromrun Execute run starting from (Used for parallel runs on different vms)
--torun Execute run till (Used for parallel runs on different vms)
--run-with-theme Run all core features with specified theme.
-h, --help Print out this help
@@ -120,8 +118,6 @@ array_walk($unrecognised, function (&$v) {
});
$extraopts = $unrecognised;
$tags = '';
if ($options['profile']) {
$profile = $options['profile'];
@@ -174,33 +170,6 @@ if (empty($parallelrun)) {
exit($code);
}
// Update config file if tags defined.
if ($tags) {
define('ABORT_AFTER_CONFIG_CANCEL', true);
require("$CFG->dirroot/lib/setup.php");
// Hack to set proper dataroot and wwwroot.
$behatdataroot = $CFG->behat_dataroot;
$behatwwwroot = $CFG->behat_wwwroot;
for ($i = 1; $i <= $parallelrun; $i++) {
$CFG->behatrunprocess = $i;
if (!empty($CFG->behat_parallel_run[$i - 1]['behat_wwwroot'])) {
$CFG->behat_wwwroot = $CFG->behat_parallel_run[$i - 1]['behat_wwwroot'];
} else {
$CFG->behat_wwwroot = $behatwwwroot . "/" . BEHAT_PARALLEL_SITE_NAME . $i;
}
if (!empty($CFG->behat_parallel_run[$i - 1]['behat_dataroot'])) {
$CFG->behat_dataroot = $CFG->behat_parallel_run[$i - 1]['behat_dataroot'];
} else {
$CFG->behat_dataroot = $behatdataroot . $i;
}
behat_config_manager::update_config_file('', true, $tags, $options['run-with-theme'], $parallelrun);
}
$CFG->behat_dataroot = $behatdataroot;
$CFG->behat_wwwroot = $behatwwwroot;
unset($CFG->behatrunprocess);
}
$cmds = array();
echo "Running " . ($options['torun'] - $options['fromrun'] + 1) . " parallel behat sites:" . PHP_EOL;