1
0
Fork 0
mirror of synced 2024-11-26 10:05:34 -05:00
dotbot/test/test-lib.bash

60 lines
1.1 KiB
Bash
Raw Normal View History

DEBUG=${DEBUG:-false}
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'
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
}
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
}
initialize() {
check_env
2015-05-05 19:58:25 -04:00
echo "${test_description}"
mkdir -p "${DOTFILES}"
cd
}
run_dotbot() {
(
cat > "${DOTFILES}/${INSTALL_CONF}"
${DOTBOT_EXEC} -c "${DOTFILES}/${INSTALL_CONF}" "${@}"
2015-05-05 19:58:25 -04:00
)
}
run_dotbot_json() {
(
cat > "${DOTFILES}/${INSTALL_CONF_JSON}"
${DOTBOT_EXEC} -c "${DOTFILES}/${INSTALL_CONF_JSON}" "${@}"
)
}
2015-05-05 19:58:25 -04:00
initialize