2020-01-03 15:20:00 -05:00
|
|
|
DOTBOT_EXEC="${BASEDIR}/bin/dotbot"
|
2020-12-18 14:34:28 -05:00
|
|
|
DOTFILES="${HOME}/dotfiles"
|
2015-05-05 19:58:25 -04:00
|
|
|
INSTALL_CONF='install.conf.yaml'
|
2016-01-13 11:29:12 -05:00
|
|
|
INSTALL_CONF_JSON='install.conf.json'
|
2015-05-05 19:58:25 -04:00
|
|
|
|
|
|
|
test_run_() {
|
|
|
|
if ! ${DEBUG}; then
|
|
|
|
(eval "$*") >/dev/null 2>&1
|
|
|
|
else
|
|
|
|
(eval "$*")
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
test_expect_success() {
|
|
|
|
local tag=${1} && shift
|
|
|
|
if ! test_run_ "$@"; then
|
|
|
|
>&2 echo "- ${tag} failed."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
test_expect_failure() {
|
|
|
|
local tag=${1} && shift
|
|
|
|
if test_run_ "$@"; then
|
|
|
|
>&2 echo "- ${tag} failed."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-05-27 12:58:55 -04:00
|
|
|
skip_tests() {
|
|
|
|
# exit with special exit code picked up by driver-lib.bash
|
|
|
|
exit 42
|
|
|
|
}
|
|
|
|
|
2020-01-03 15:20:00 -05:00
|
|
|
check_env() {
|
|
|
|
if [ "${DOTBOT_TEST}" != "true" ]; then
|
|
|
|
>&2 echo "test must be run by test driver"
|
2015-05-05 19:58:25 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-05-27 12:58:55 -04:00
|
|
|
# run comparison check on python version; args:
|
|
|
|
# $1 - comparison operator (e.g. '>=')
|
|
|
|
# $2 - version number, to be passed to python (e.g. '3', '3.5', '3.6.4')
|
|
|
|
# status code will reflect if comparison is true/false
|
|
|
|
# e.g. `check_python_version '>=' 3.5`
|
|
|
|
check_python_version() {
|
|
|
|
check="$1"
|
|
|
|
version="$(echo "$2" | tr . , )"
|
|
|
|
# this call to just `python` will work in the Vagrant-based testing VM
|
|
|
|
# because `pyenv` will always create a link to the "right" version.
|
|
|
|
python -c "import sys; exit( not (sys.version_info ${check} (${version})) )"
|
|
|
|
}
|
|
|
|
|
2015-05-05 19:58:25 -04:00
|
|
|
initialize() {
|
2020-01-03 15:20:00 -05:00
|
|
|
check_env
|
2015-05-05 19:58:25 -04:00
|
|
|
echo "${test_description}"
|
|
|
|
mkdir -p "${DOTFILES}"
|
|
|
|
cd
|
|
|
|
}
|
|
|
|
|
|
|
|
run_dotbot() {
|
|
|
|
(
|
2018-05-24 12:00:13 -04:00
|
|
|
cat > "${DOTFILES}/${INSTALL_CONF}"
|
2018-05-30 09:41:55 -04:00
|
|
|
${DOTBOT_EXEC} -c "${DOTFILES}/${INSTALL_CONF}" "${@}"
|
2015-05-05 19:58:25 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2016-01-13 11:29:12 -05:00
|
|
|
run_dotbot_json() {
|
|
|
|
(
|
2018-05-24 12:00:13 -04:00
|
|
|
cat > "${DOTFILES}/${INSTALL_CONF_JSON}"
|
2018-05-30 09:41:55 -04:00
|
|
|
${DOTBOT_EXEC} -c "${DOTFILES}/${INSTALL_CONF_JSON}" "${@}"
|
2016-01-13 11:29:12 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2015-05-05 19:58:25 -04:00
|
|
|
initialize
|