Skip to content

Commit

Permalink
Introduce die bash functions.
Browse files Browse the repository at this point in the history
Those facilitate result reporting in bash tests.
soft_die just returns, while die exits.
  • Loading branch information
matejak committed Apr 7, 2021
1 parent 97fb6ca commit cbae8ba
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_common.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,18 @@ xsed() {
esac
}

# Args:
# $1: The text string to print to stderr
# $2: The return code (optional, default is 1)
log_and_fail() {
printf '%s' "$1" >&2
return ${2:-1}
}

# Args: Same as with log_and_fail
die() {
log_and_fail "$1" "$2"
exit $?
}

export -f assert_exists

0 comments on commit cbae8ba

Please sign in to comment.