From 3586901f8f8187a2961bfeab412582837a56c64e Mon Sep 17 00:00:00 2001 From: Islam AbdelRahman Date: Thu, 25 Aug 2016 12:53:26 -0700 Subject: [PATCH] cat tests logs sorted by exit code Summary: Instead of doing a cat for all the log files, we first sort them and by exit code and cat the failing tests at the end. This will make it easier to debug failing tests, since we will just need to look at the end of the logs instead of searching in them Test Plan: run it locally Reviewers: sdong, yiwu, lightmark, kradhakrishnan, yhchiang, andrewkr Reviewed By: andrewkr Subscribers: andrewkr, dhruba Differential Revision: https://reviews.facebook.net/D62211 --- arcanist_util/config/RocksDBCommonHelper.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/arcanist_util/config/RocksDBCommonHelper.php b/arcanist_util/config/RocksDBCommonHelper.php index cc876c457..42ff2b9bd 100644 --- a/arcanist_util/config/RocksDBCommonHelper.php +++ b/arcanist_util/config/RocksDBCommonHelper.php @@ -128,9 +128,24 @@ function getSteps($applyDiff, $diffID, $username, $test) { . "; "; } + // shell command to sort the tests based on exit code and print + // the output of the log files. + $cat_sorted_logs = " + while read code log_file; + do echo \"################ cat \$log_file [exit_code : \$code] ################\"; + cat \$log_file; + done < <(tail -n +2 LOG | sort -k7,7n -k4,4gr | awk '{print \$7,\$NF}')"; + + // Shell command to cat all log files + $cat_all_logs = "for f in `ls t/!(run-*)`; do echo \$f;cat \$f; done"; + + // If LOG file exist use it to cat log files sorted by exit code, otherwise + // cat everything + $logs_cmd = "if [ -f LOG ]; then {$cat_sorted_logs}; else {$cat_all_logs}; fi"; + $cmd = $cmd . " cat /tmp/precommit-check.log" - . "; shopt -s extglob; for f in `ls t/!(run-*)`; do echo \$f" - . "; cat \$f; done; shopt -u extglob; [[ \$exit_code -eq 0 ]]"; + . "; shopt -s extglob; {$logs_cmd}" + . "; shopt -u extglob; [[ \$exit_code -eq 0 ]]"; assert(strlen($cmd) > 0); $run_test = array( -- GitLab