MDL-49772 behat: Added support to updatestep file by parallel run
This commit is contained in:
@@ -97,7 +97,7 @@ if (!empty($options['help'])) {
|
||||
$cwd = getcwd();
|
||||
|
||||
// For drop option check if parallel site.
|
||||
if ((empty($options['parallel'])) && $options['drop']) {
|
||||
if ((empty($options['parallel'])) && ($options['drop']) || $options['updatesteps']) {
|
||||
// Get parallel run info from first run.
|
||||
$options['parallel'] = behat_config_manager::get_parallel_test_runs($options['fromrun']);
|
||||
}
|
||||
@@ -172,6 +172,26 @@ if ($options['diag'] || $options['enable'] || $options['disable']) {
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($options['updatesteps']) {
|
||||
// Rewrite config file to ensure we have all the features covered.
|
||||
if (empty($options['parallel'])) {
|
||||
behat_config_manager::update_config_file();
|
||||
} else {
|
||||
// Update config file, ensuring we have up-to-date behat.yml.
|
||||
for ($i = $options['fromrun']; $i <= $options['torun']; $i++) {
|
||||
$CFG->behatrunprocess = $i;
|
||||
behat_config_manager::update_config_file();
|
||||
}
|
||||
unset($CFG->behatrunprocess);
|
||||
}
|
||||
|
||||
// Do it sequentially as it's fast and need to be displayed nicely.
|
||||
foreach (array_chunk($cmds, 1, true) as $cmd) {
|
||||
$processes = cli_execute_parallel($cmd, __DIR__);
|
||||
print_sequential_output($processes);
|
||||
}
|
||||
exit(0);
|
||||
|
||||
} else {
|
||||
// We should never reach here.
|
||||
echo $help;
|
||||
|
||||
@@ -199,9 +199,6 @@ if ($options['install']) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Rewrite config file to ensure we have all the features covered.
|
||||
behat_config_manager::update_config_file();
|
||||
|
||||
// Run behat command to get steps in feature files.
|
||||
$featurestepscmd = behat_command::get_behat_command(true);
|
||||
$featurestepscmd .= ' --config ' . behat_config_manager::get_behat_cli_config_filepath();
|
||||
@@ -263,6 +260,10 @@ function print_update_step_output($process, $featurestepfile) {
|
||||
$steps[$step[0]] = $step[1];
|
||||
}
|
||||
}
|
||||
|
||||
if ($existing = @json_decode(file_get_contents($featurestepfile), true)) {
|
||||
$steps = array_merge($existing, $steps);
|
||||
}
|
||||
arsort($steps);
|
||||
|
||||
if (!@file_put_contents($featurestepfile, json_encode($steps, JSON_PRETTY_PRINT))) {
|
||||
|
||||
@@ -273,6 +273,13 @@ class behat_config_manager {
|
||||
* @return int
|
||||
*/
|
||||
public final static function get_parallel_test_runs($runprocess = 0) {
|
||||
global $CFG;
|
||||
|
||||
// Optimise reading this information from file.
|
||||
if (!empty($CFG->behatparallelprocesses)) {
|
||||
return $CFG->behatparallelprocesses;
|
||||
}
|
||||
|
||||
$parallelrun = 0;
|
||||
// Get parallel run info from first file and last file.
|
||||
$parallelrunconfigfile = self::get_parallel_test_file_path($runprocess);
|
||||
@@ -282,6 +289,8 @@ class behat_config_manager {
|
||||
}
|
||||
}
|
||||
|
||||
$CFG->behatparallelprocesses = $parallelrun;
|
||||
|
||||
return $parallelrun;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user