summaryrefslogtreecommitdiff
path: root/test/test_travis
diff options
context:
space:
mode:
authorAnish Athalye <me@anishathalye.com>2020-01-03 15:20:00 -0500
committerAnish Athalye <me@anishathalye.com>2020-01-03 15:34:46 -0500
commit6d24613b0b453e546fa4e9defc695d8f982743c9 (patch)
tree7e5124b2606284ef761cd69fcb8892d0038d297d /test/test_travis
parent1e1885c45a28190dc1cbde993a9ddcf1729ee4d1 (diff)
Unify Vagrant and Travis-CI tests
This patch makes the tests (including the test driver) run entirely inside Vagrant, which avoids calling the very slow `vagrant` driver many times for running the tests. On my machine, `./test` runs in 22 seconds, down from hundreds of seconds prior to this patch. This also has the nice side effect of matching how the Travis CI tests were run, so there's no need for a separate `test_travis` anymore.
Diffstat (limited to 'test/test_travis')
-rwxr-xr-xtest/test_travis81
1 files changed, 0 insertions, 81 deletions
diff --git a/test/test_travis b/test/test_travis
deleted file mode 100755
index 79439e1..0000000
--- a/test/test_travis
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-# For debug only:
-# export DEBUG=true
-# set -x
-# set -v
-
-export BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-
-# Prevent execution outside of Travis CI builds
-if [[ "${TRAVIS}" != true || "${CI}" != true ]]; then
- echo "Error: `basename "$0"` should only be used on Travis"
- exit 2
-fi
-
-# Travis runs do not rely on Vagrant
-export USE_VAGRANT=false
-export DOTBOT_EXEC="${BASEDIR}/bin/dotbot"
-
-cd "${BASEDIR}"
-. "test/driver-lib.bash"
-
-travis_initialize() {
- echo "initializing."
- tests_run=0
- tests_passed=0
- tests_failed=0
- tests_total="${1}"
- local plural="" && [ "${tests_total}" -gt 1 ] && plural="s"
- printf -- "running %d test%s...\n\n" "${tests_total}" "${plural}"
-}
-
-travis_cleanup() {
- # Remove all dotfiles installed since the start, ignoring the main
- # dotfiles directory, and the dotbot source directory
- find ~ -mindepth 1 -newermt "${date_stamp}" \
- -not \( -path ~ -o -path "${BASEDIR}/*" \
- -o -path ~/dotfiles \) \
- -exec rm -rf {} +
-}
-
-travis_run_test() {
- tests_run=$((tests_run + 1))
- printf '[%d/%d] (%s)\n' "${tests_run}" "${tests_total}" "${1}"
- cd ${BASEDIR}/test/tests
- if bash ${1} ; then
- pass
- else
- fail
- fi
- travis_cleanup || die "unable to clean up system."
-}
-
-date_stamp="$(date --rfc-3339=ns)"
-start="$(date +%s)"
-
-declare -a tests=()
-
-if [ $# -eq 0 ]; then
- while read file; do
- tests+=("${file}")
- done < <(find ${BASEDIR}/test/tests -type f -name '*.bash')
-else
- tests=("$@")
-fi
-
-travis_initialize "${#tests[@]}"
-
-for file in "${tests[@]}"; do
- travis_run_test "$(basename "${file}")"
-done
-
-if report; then
- ret=0
-else
- ret=1
-fi
-
-echo "(tests run in $(($(date +%s) - start)) seconds)"
-exit ${ret}