diff options
author | Anish Athalye <me@anishathalye.com> | 2015-05-05 19:58:25 -0400 |
---|---|---|
committer | Anish Athalye <me@anishathalye.com> | 2015-05-05 20:11:46 -0400 |
commit | eeab507d151351b3643b6608cd3a68863234f3e6 (patch) | |
tree | 205824cd0640a6121bdf93d3ee31527c62dbf757 /test/test-lib.bash | |
parent | 49181b06660c8fd66873676001500db52b1f8b68 (diff) |
Add testing framework and tests
Diffstat (limited to 'test/test-lib.bash')
-rw-r--r-- | test/test-lib.bash | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/test-lib.bash b/test/test-lib.bash new file mode 100644 index 0000000..425ae56 --- /dev/null +++ b/test/test-lib.bash @@ -0,0 +1,51 @@ +DEBUG=false +DOTFILES='/home/vagrant/dotfiles' +INSTALL_CONF='install.conf.yaml' + +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() { + check_vm + echo "${test_description}" + mkdir -p "${DOTFILES}" + cd +} + +run_dotbot() { + ( + cd "${DOTFILES}" + cat > "${INSTALL_CONF}" + /dotbot/bin/dotbot -d . -c "${INSTALL_CONF}" "${@}" + ) +} + +initialize |