Skip to content

Commit

Permalink
Merge branch 'wip-mdl-49772' of https://github.com/rajeshtaneja/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed May 26, 2015
2 parents 84152b6 + 91a96d4 commit 777cb3e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
22 changes: 21 additions & 1 deletion admin/tool/behat/cli/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
$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']);
}
Expand Down Expand Up @@ -172,6 +172,26 @@
}
}

} 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;
Expand Down
7 changes: 4 additions & 3 deletions admin/tool/behat/cli/util_single_run.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,6 @@
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();
Expand Down Expand Up @@ -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))) {
Expand Down
9 changes: 9 additions & 0 deletions lib/behat/classes/behat_config_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ public final static function get_parallel_test_file_path($runprocess = 0) {
* @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);
Expand All @@ -282,6 +289,8 @@ public final static function get_parallel_test_runs($runprocess = 0) {
}
}

$CFG->behatparallelprocesses = $parallelrun;

return $parallelrun;
}

Expand Down

0 comments on commit 777cb3e

Please sign in to comment.