1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-12-27 06:59:45 +01:00

Add functionality to check the bash version

Bats has know issues with old versions of bash < 4.1 as explained
in issues #49 and #140.
These issues create confusion because bats runs the tests without
errors, but the results of the tests are wrong.
This patchs adds the capability to check for the bash version and
exit if it's not supported.
This commit is contained in:
Antonio Ojea 2017-09-22 09:51:53 +02:00
parent 03608115df
commit 2e44b920c9

View File

@ -1,6 +1,16 @@
#!/usr/bin/env bash
set -e
check_bash_version() {
if [ ${BASH_VERSINFO[0]} -lt 4 ] ; then
echo "Bats has known issues with old versions of Bash"
echo "and doesn't work as expected, see issue #49 and #140"
echo "in https://github.com/sstephenson/bats/issues/"
echo "Please use Bash versions greater or equal to 4.1"
exit 1
fi
}
version() {
echo "Bats 0.4.0"
}
@ -52,6 +62,7 @@ expand_path() {
} || echo "$1"
}
check_bash_version
BATS_LIBEXEC="$(abs_dirname "$0")"
export BATS_PREFIX="$(abs_dirname "$BATS_LIBEXEC")"
export BATS_CWD="$(abs_dirname .)"