2016-01-16 00:01:40 -05:00
|
|
|
DEBUG=${DEBUG:-false}
|
|
|
|
USE_VAGRANT=${USE_VAGRANT:-true}
|
2018-03-27 21:18:39 -04:00
|
|
|
if ${USE_VAGRANT}; then
|
|
|
|
DOTBOT_EXEC=${DOTBOT_EXEC:-"python /dotbot/bin/dotbot"}
|
|
|
|
else
|
|
|
|
DOTBOT_EXEC=${DOTBOT_EXEC:-"/dotbot/bin/dotbot"}
|
|
|
|
fi
|
2016-01-16 00:01:40 -05:00
|
|
|
DOTFILES="/home/$(whoami)/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
|
|
|
|
}
|
|
|
|
|
|
|
|
check_vm() {
|
|
|
|
if [ "$(whoami)" != "vagrant" ]; then
|
|
|
|
>&2 echo "test can't run outside vm!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
initialize() {
|
2016-01-16 00:01:40 -05:00
|
|
|
if ${USE_VAGRANT}; then
|
|
|
|
check_vm
|
|
|
|
fi
|
2015-05-05 19:58:25 -04:00
|
|
|
echo "${test_description}"
|
|
|
|
mkdir -p "${DOTFILES}"
|
|
|
|
cd
|
|
|
|
}
|
|
|
|
|
|
|
|
run_dotbot() {
|
|
|
|
(
|
|
|
|
cd "${DOTFILES}"
|
|
|
|
cat > "${INSTALL_CONF}"
|
2016-01-16 00:01:40 -05:00
|
|
|
${DOTBOT_EXEC} -d . -c "${INSTALL_CONF}" "${@}"
|
2015-05-05 19:58:25 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2016-01-13 11:29:12 -05:00
|
|
|
run_dotbot_json() {
|
|
|
|
(
|
|
|
|
cd "${DOTFILES}"
|
|
|
|
cat > "${INSTALL_CONF_JSON}"
|
2016-01-16 00:01:40 -05:00
|
|
|
${DOTBOT_EXEC} -d . -c "${INSTALL_CONF_JSON}" "${@}"
|
2016-01-13 11:29:12 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2015-05-05 19:58:25 -04:00
|
|
|
initialize
|