diff options
author | Anish Athalye <me@anishathalye.com> | 2018-03-27 20:56:55 -0400 |
---|---|---|
committer | Anish Athalye <me@anishathalye.com> | 2018-03-27 20:56:55 -0400 |
commit | b7022f4abb7ff9a6b816ecb16038ff5b2f6559fb (patch) | |
tree | 89f2f4857a25f04260db18d315074f3f103ce24f /test/driver-lib.bash | |
parent | 9ff1db16726afaee890092c20b0a23d7c5d35d1d (diff) |
Speed up Vagrant tests
This patch removes the snapshot/rollback system for the tests and
replaces it with a simple cleanup script that removes the appropriate
files from the VM's $HOME before every test. A side benefit is that
there is no more dependency on the Sahara plugin.
The cleanup script may not provide as good isolation between independent
tests as the previous setup, but it is orders of magnitude faster to run
without a VM rollback for every single test, and it does not break any
of the current tests.
Diffstat (limited to 'test/driver-lib.bash')
-rw-r--r-- | test/driver-lib.bash | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/test/driver-lib.bash b/test/driver-lib.bash index 56a0740..02a71a5 100644 --- a/test/driver-lib.bash +++ b/test/driver-lib.bash @@ -31,10 +31,6 @@ check_prereqs() { >&2 echo "vagrant vm must be running." return 1 fi - if ! (vagrant plugin list | grep '^sahara\s\+') >/dev/null 2>&1; then - >&2 echo "vagrant plugin 'sahara' is not installed." - return 1 - fi } until_success() { @@ -56,23 +52,26 @@ wait_for_vagrant() { until_success vagrant ssh -c 'exit' } -rollback() { - vagrant sandbox rollback >/dev/null 2>&1 && - wait_for_vagrant && - vagrant rsync >/dev/null 2>&1 +cleanup() { + vagrant ssh -c " + find . -not \\( \ + -path './.pyenv' -o \ + -path './.pyenv/*' -o \ + -path './.bashrc' -o \ + -path './.profile' -o \ + -path './.ssh' -o \ + -path './.ssh/*' \ + \\) -delete" >/dev/null 2>&1 } initialize() { echo "initializing." - vagrant sandbox on >/dev/null 2>&1 if ! vagrant ssh -c "pyenv local ${2}" >/dev/null 2>&1; then - wait_for_vagrant && vagrant sandbox rollback >/dev/null 2>&1 - wait_for_vagrant if ! vagrant ssh -c "pyenv install -s ${2} && pyenv local ${2}" >/dev/null 2>&1; then die "could not install python ${2}" fi - vagrant sandbox commit >/dev/null 2>&1 fi + vagrant rsync >/dev/null 2>&1 tests_run=0 tests_passed=0 tests_failed=0 @@ -96,7 +95,7 @@ fail() { run_test() { tests_run=$((tests_run + 1)) printf '[%d/%d] (%s)\n' "${tests_run}" "${tests_total}" "${1}" - rollback || die "unable to rollback vm." # start with a clean slate + cleanup vagrant ssh -c "pyenv local ${2}" >/dev/null 2>&1 if vagrant ssh -c "cd /dotbot/test/tests && bash ${1}" 2>/dev/null; then pass |