diff options
author | David Spickett <david.spickett@linaro.org> | 2020-05-13 14:27:20 +0100 |
---|---|---|
committer | David Spickett <david.spickett@linaro.org> | 2020-05-14 14:33:09 +0000 |
commit | b3334e58e24ea4ade3088c620dec315e62042754 (patch) | |
tree | c63901b67c695c61245ce88f8c407567ed3aba70 /jenkins-helpers.sh | |
parent | f362d7f03b41898cb77901b01afab5efbf59016c (diff) |
tcwg_bmk/round-robin: Add assert_with_msg function
This acts like assert but prints a message
if the assert fails. This will be visible in
the Jenkins logs and give us a unique string
to look for in the abscence of traceback for
shell scripts.
Two instances of returning false in check_regression
have had echos added to them, instead of asserts.
This is because they are not hard failures,
and may be handled by the caller. (run_step)
I have only converted the tcwg-bmk relevant
scripts to assert_with_msg so far, as a proof
of concept.
Change-Id: I3b1badf09e4856c80b973ca8b23088626ed66b0a
Diffstat (limited to 'jenkins-helpers.sh')
-rw-r--r-- | jenkins-helpers.sh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh index ccfef2de..e77b07e0 100644 --- a/jenkins-helpers.sh +++ b/jenkins-helpers.sh @@ -23,6 +23,21 @@ abs_path () ) } +# Assert that $@[1:] returns success. +# $1 should be a message to print on failure e.g. +# assert "will always fail" false +assert_with_msg () +{ + ( + set -euf -o pipefail + + local failure_message=$1 + shift + + eval "$@" || (echo "$failure_message" && exit 1) + ) +} + # Assert that $@ returns success. assert () { |