From a4dcc3439667cb4111e323237d083e9f2c9c346f Mon Sep 17 00:00:00 2001 From: Lars Karlitski Date: Sun, 2 Jun 2019 15:05:17 +0200 Subject: [PATCH] test_cli.sh: Return beakerlib's exit code Read the return status directly from beakerlib's TestResults file. This is more robust when running the same test multiple times. --- tests/test_cli.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/test_cli.sh b/tests/test_cli.sh index 1b267abc..154b150d 100755 --- a/tests/test_cli.sh +++ b/tests/test_cli.sh @@ -3,8 +3,7 @@ set -eu -# setup -rm -rf /var/tmp/beakerlib-*/ +export BEAKERLIB_DIR=$(mktemp -d /tmp/composer-test.XXXXXX) function setup_tests { local share_dir=$1 @@ -103,8 +102,11 @@ else systemctl start lorax-composer fi -# look for failures -grep RESULT_STRING /var/tmp/beakerlib-*/TestResults | grep -v PASS && exit 1 +. $BEAKERLIB_DIR/TestResults -# explicit return code for Makefile -exit 0 +if [ $TESTRESULT_RESULT_ECODE != 0 ]; then + echo "Test failed. Leaving log in $BEAKERLIB_DIR" + exit $TESTRESULT_RESULT_ECODE +fi + +rm -rf $BEAKERLIB_DIR