From caa444b44f1ce1974bd9f46c68e45ff26d251bdf Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 30 Oct 2024 11:28:53 -0400 Subject: Implement missing SKIP conditions * The not (bang) overrides the return code. Split the command from the if-statement to obtain the real code, not just true/false * Print the last n lines of the log only when there's something to print --- tests/setup.sh | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'tests/setup.sh') diff --git a/tests/setup.sh b/tests/setup.sh index 743fafd..0875cac 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -103,13 +103,23 @@ run_command() { local cmd="${@}" local lines_on_error=100 /bin/echo "Testing: $cmd " - if ! $cmd &>"$logfile"; then - echo "... FAIL" - echo "#" - echo "# Last $lines_on_error line(s) follow:" - echo "#" - tail -n $lines_on_error "$logfile" - (( STASIS_TEST_RESULT_FAIL++ )) + + $cmd &>"$logfile" + code=$? + if (( code )); then + if (( code == 127 )); then + echo "... SKIP" + (( STASIS_TEST_RESULT_SKIP++ )) + else + echo "... FAIL" + if (( $(wc -c "$logfile" | cut -d ' ' -f 1) > 1 )); then + echo "#" + echo "# Last $lines_on_error line(s) follow:" + echo "#" + tail -n $lines_on_error "$logfile" + fi + (( STASIS_TEST_RESULT_FAIL++ )) + fi else echo "... PASS" (( STASIS_TEST_RESULT_PASS++ )) -- cgit