MDL-46891 behat: Improved exit status of parallel run

Exit status should contain pass/fail information
of each run it is executing. Every bit of status
will have information of pass/fail status of parallel
process
This commit is contained in:
Rajesh Taneja 2016-03-04 13:33:41 +08:00
parent 0e1c34e51a
commit c4c2cd59eb

View file

@ -226,22 +226,27 @@ $exitcodes = print_combined_run_output($processes, $stoponfail);
$time = round(microtime(true) - $time, 1); $time = round(microtime(true) - $time, 1);
echo "Finished in " . gmdate("G\h i\m s\s", $time) . PHP_EOL . PHP_EOL; echo "Finished in " . gmdate("G\h i\m s\s", $time) . PHP_EOL . PHP_EOL;
ksort($exitcodes);
// Print exit info from each run. // Print exit info from each run.
$status = false; // Status bits contains pass/fail status of parallel runs.
$status = 0;
$processcounter = 0;
foreach ($exitcodes as $exitcode) { foreach ($exitcodes as $exitcode) {
$status = (bool)$status || (bool)$exitcode; if ($exitcode) {
$status |= (1 << $processcounter);
}
$processcounter++;
} }
// Run finished. Show exit code and output from individual process. // Run finished. Show exit code and output from individual process.
$verbose = empty($options['verbose']) ? false : true; $verbose = empty($options['verbose']) ? false : true;
$verbose = $verbose || $status; $verbose = $verbose || !empty($status);
// Show exit code from each process, if any process failed. // Show exit code from each process, if any process failed.
if ($verbose) { if ($verbose) {
// Echo exit codes. // Echo exit codes.
echo "Exit codes for each behat run: " . PHP_EOL; echo "Exit codes for each behat run: " . PHP_EOL;
ksort($exitcodes);
foreach ($exitcodes as $run => $exitcode) { foreach ($exitcodes as $run => $exitcode) {
echo $run . ": " . $exitcode . PHP_EOL; echo $run . ": " . $exitcode . PHP_EOL;
} }
@ -263,7 +268,7 @@ print_each_process_info($processes, $verbose);
// Remove site symlink if necessary. // Remove site symlink if necessary.
behat_config_manager::drop_parallel_site_links(); behat_config_manager::drop_parallel_site_links();
exit((int) $status); exit($status);
/** /**
* Signal handler for terminal exit. * Signal handler for terminal exit.