From c4c2cd59eb1c46aef080633bf85325077ef97ef8 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 4 Mar 2016 13:33:41 +0800 Subject: [PATCH] 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 --- admin/tool/behat/cli/run.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/admin/tool/behat/cli/run.php b/admin/tool/behat/cli/run.php index 6808ebdf09a..3df999a3cd6 100644 --- a/admin/tool/behat/cli/run.php +++ b/admin/tool/behat/cli/run.php @@ -226,22 +226,27 @@ $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 = false; +// Status bits contains pass/fail status of parallel runs. +$status = 0; +$processcounter = 0; 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. $verbose = empty($options['verbose']) ? false : true; -$verbose = $verbose || $status; +$verbose = $verbose || !empty($status); // Show exit code from each process, if any process failed. if ($verbose) { // Echo exit codes. echo "Exit codes for each behat run: " . PHP_EOL; - ksort($exitcodes); foreach ($exitcodes as $run => $exitcode) { echo $run . ": " . $exitcode . PHP_EOL; } @@ -263,7 +268,7 @@ print_each_process_info($processes, $verbose); // Remove site symlink if necessary. behat_config_manager::drop_parallel_site_links(); -exit((int) $status); +exit($status); /** * Signal handler for terminal exit.