foreach (array_chunk($cmds, $options['maxruns'], true) as $chunk) { $processes = cli_execute_parallel($chunk, __DIR__); $exitcodes = print_combined_install_output($processes); foreach ($exitcodes as $name => $exitcode) { if ($exitcode != 0) { echo "Failed process [[{$name}]]" . PHP_EOL; echo $processes[$name]->getOutput(); echo PHP_EOL; echo $processes[$name]->getErrorOutput(); echo PHP_EOL . PHP_EOL; } $status = (bool) $status || (bool) $exitcode; } } } else { $processes = cli_execute_parallel($cmds, __DIR__); $exitcodes = print_combined_install_output($processes); foreach ($exitcodes as $name => $exitcode) { if ($exitcode != 0) { echo "Failed process [[{$name}]]" . PHP_EOL; echo $processes[$name]->getOutput(); echo PHP_EOL; echo $processes[$name]->getErrorOutput(); echo PHP_EOL . PHP_EOL; } $status = (bool) $status || (bool) $exitcode; } } } else { // We should never reach here. echo $help;
exit($code); } else { if ($options['updatesteps']) { if (defined('BEHAT_FEATURE_STEP_FILE') && BEHAT_FEATURE_STEP_FILE) { $behatstepfile = BEHAT_FEATURE_STEP_FILE; } else { echo "BEHAT_FEATURE_STEP_FILE is not set, please ensure you set this to writable file" . PHP_EOL; 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(); $featurestepscmd .= ' --dry-run --format=moodle_step_count'; $processes = cli_execute_parallel(array($featurestepscmd), __DIR__ . "/../../../../"); $status = print_update_step_output(array_pop($processes), $behatstepfile); exit($status); } else { echo $help; exit(1); } } } } } } exit(0); /** * Print update progress as dots for updating feature file step list. *
$behatconfigpath = behat_config_manager::get_behat_cli_config_filepath($i); // Command to execute behat run. $cmds[BEHAT_PARALLEL_SITE_NAME . $i] = $behatcommand . ' --config ' . $behatconfigpath . " " . $myopts; echo "[" . BEHAT_PARALLEL_SITE_NAME . $i . "] " . $cmds[BEHAT_PARALLEL_SITE_NAME . $i] . PHP_EOL; } if (empty($cmds)) { echo "No commands to execute " . PHP_EOL; exit(1); } // Create site symlink if necessary. if (!behat_config_manager::create_parallel_site_links($options['fromrun'], $options['torun'])) { echo "Check permissions. If on windows, make sure you are running this command as admin" . PHP_EOL; exit(1); } // Execute all commands, relative to moodle root directory. $processes = cli_execute_parallel($cmds, __DIR__ . "/../../../../"); $stoponfail = empty($options['stop-on-failure']) ? false : true; // Print header. print_process_start_info($processes); // Print combined run o/p from processes. $exitcodes = print_combined_run_output($processes, $stoponfail); $time = round(microtime(true) - $time, 1); echo "Finished in " . gmdate("G\\h i\\m s\\s", $time) . PHP_EOL . PHP_EOL; ksort($exitcodes); // Print exit info from each run. // Status bits contains pass/fail status of parallel runs. $status = 0; $processcounter = 0; foreach ($exitcodes as $exitcode) { if ($exitcode) { $status |= 1 << $processcounter;
for ($i = $options['fromrun']; $i <= $options['torun']; $i++) { $CFG->behatrunprocess = $i; // Options parameters to be added to each run. $myopts = !empty($options['replace']) ? str_replace($options['replace'], $i, $extraopts) : $extraopts; $behatcommand = behat_command::get_behat_command(); $behatconfigpath = behat_config_manager::get_behat_cli_config_filepath($i); // Command to execute behat run. $cmds[BEHAT_PARALLEL_SITE_NAME . $i] = $behatcommand . ' --config ' . $behatconfigpath . " " . $myopts; echo "[" . BEHAT_PARALLEL_SITE_NAME . $i . "] " . $cmds[BEHAT_PARALLEL_SITE_NAME . $i] . PHP_EOL; } if (empty($cmds)) { echo "No commands to execute " . PHP_EOL; exit(1); } // Execute all commands. $processes = cli_execute_parallel($cmds); $stoponfail = empty($options['stop-on-failure']) ? false : true; // Print header. print_process_start_info($processes); // Print combined run o/p from processes. $exitcodes = print_combined_run_output($processes, $stoponfail); $time = round(microtime(true) - $time, 1); echo "Finished in " . gmdate("G\\h i\\m s\\s", $time) . PHP_EOL . PHP_EOL; // Print exit info from each run. $status = false; foreach ($exitcodes as $exitcode) { $status = (bool) $status || (bool) $exitcode; } // Show exit code from each process, if any process failed. if ($status) { echo "Exit codes: " . implode(" ", $exitcodes) . PHP_EOL;