diff --git a/test/composertest.py b/test/composertest.py index 6258da30..2a5f990c 100644 --- a/test/composertest.py +++ b/test/composertest.py @@ -76,9 +76,14 @@ class ComposerTestCase(unittest.TestCase): return subprocess.run(self.ssh_command + command, **args) def runCliTest(self, script): + extra_env = [] + if self.sit: + extra_env.append("COMPOSER_TEST_FAIL_FAST=1") + r = self.execute(["CLI=/usr/bin/composer-cli", "TEST=" + self.id(), "PACKAGE=composer-cli", + *extra_env, "/tests/test_cli.sh", script]) self.assertEqual(r.returncode, 0) diff --git a/tests/cli/lib/lib.sh b/tests/cli/lib/lib.sh index 9aeb9631..98fa1a76 100755 --- a/tests/cli/lib/lib.sh +++ b/tests/cli/lib/lib.sh @@ -1,5 +1,21 @@ #!/usr/bin/env bash +# Monkey-patch beakerlib to exit on first failure if COMPOSER_TEST_FAIL_FAST is +# set. https://github.com/beakerlib/beakerlib/issues/42 +if [ "$COMPOSER_TEST_FAIL_FAST" == "1" ]; then + eval "original$(declare -f __INTERNAL_LogAndJournalFail)" + + __INTERNAL_LogAndJournalFail () { + original__INTERNAL_LogAndJournalFail + + # end test somewhat cleanly so that beakerlib logs the FAIL correctly + rlPhaseEnd + rlJournalEnd + + exit 1 + } +fi + # a generic helper function unifying the specific checks executed on a running # image instance verify_image() { diff --git a/tests/cli/test_blueprints_sanity.sh b/tests/cli/test_blueprints_sanity.sh index 46b0e0b7..ff50bd0d 100755 --- a/tests/cli/test_blueprints_sanity.sh +++ b/tests/cli/test_blueprints_sanity.sh @@ -4,6 +4,7 @@ set -e . /usr/share/beakerlib/beakerlib.sh +. $(dirname $0)/lib/lib.sh CLI="${CLI:-./src/bin/composer-cli}" diff --git a/tests/cli/test_compose_ext4-filesystem.sh b/tests/cli/test_compose_ext4-filesystem.sh index b968f8d9..e31fe8d7 100755 --- a/tests/cli/test_compose_ext4-filesystem.sh +++ b/tests/cli/test_compose_ext4-filesystem.sh @@ -12,6 +12,7 @@ set -e . /usr/share/beakerlib/beakerlib.sh +. $(dirname $0)/lib/lib.sh CLI="${CLI:-./src/bin/composer-cli}" diff --git a/tests/cli/test_compose_google.sh b/tests/cli/test_compose_google.sh index bfe8ca54..7842bf1d 100755 --- a/tests/cli/test_compose_google.sh +++ b/tests/cli/test_compose_google.sh @@ -9,6 +9,7 @@ set -e . /usr/share/beakerlib/beakerlib.sh +. $(dirname $0)/lib/lib.sh CLI="${CLI:-./src/bin/composer-cli}" diff --git a/tests/cli/test_compose_partitioned-disk.sh b/tests/cli/test_compose_partitioned-disk.sh index 9f01425e..b229a52e 100755 --- a/tests/cli/test_compose_partitioned-disk.sh +++ b/tests/cli/test_compose_partitioned-disk.sh @@ -12,6 +12,7 @@ set -e . /usr/share/beakerlib/beakerlib.sh +. $(dirname $0)/lib/lib.sh CLI="${CLI:-./src/bin/composer-cli}" diff --git a/tests/cli/test_compose_sanity.sh b/tests/cli/test_compose_sanity.sh index f6716734..38ba65e4 100755 --- a/tests/cli/test_compose_sanity.sh +++ b/tests/cli/test_compose_sanity.sh @@ -4,6 +4,7 @@ set -e . /usr/share/beakerlib/beakerlib.sh +. $(dirname $0)/lib/lib.sh CLI="${CLI:-./src/bin/composer-cli}" diff --git a/tests/cli/test_compose_tar.sh b/tests/cli/test_compose_tar.sh index f54ea4bd..f23ec685 100755 --- a/tests/cli/test_compose_tar.sh +++ b/tests/cli/test_compose_tar.sh @@ -10,6 +10,7 @@ set -e . /usr/share/beakerlib/beakerlib.sh +. $(dirname $0)/lib/lib.sh CLI="${CLI:-./src/bin/composer-cli}"