summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnish Athalye <me@anishathalye.com>2018-03-27 21:18:39 -0400
committerAnish Athalye <me@anishathalye.com>2018-03-27 21:50:31 -0400
commita517c4c5d0b6bdd8ab3a62f3c6c3f38837354bde (patch)
treeb7252e9d8dd8ffee2dc9c1f5b94a9355cceab98c /test
parentb7022f4abb7ff9a6b816ecb16038ff5b2f6559fb (diff)
Fix bug in test harness
Because 'bin/dotbot' is a hybrid sh/Python script that finds the appropriate Python binary and then runs, the test code should not invoke it as an sh script when sh does not source the pyenv initialization script. The fix implemented in this patch is to directly run 'bin/dotbot' as a Python script using 'python', which when called from bash, will run with the correct Python version (because bash is set up to source the pyenv initialization script).
Diffstat (limited to 'test')
-rw-r--r--test/test-lib.bash6
-rw-r--r--test/tests/find-python-executable.bash6
2 files changed, 10 insertions, 2 deletions
diff --git a/test/test-lib.bash b/test/test-lib.bash
index affb5c9..008c2f8 100644
--- a/test/test-lib.bash
+++ b/test/test-lib.bash
@@ -1,6 +1,10 @@
DEBUG=${DEBUG:-false}
USE_VAGRANT=${USE_VAGRANT:-true}
-DOTBOT_EXEC=${DOTBOT_EXEC:-"/dotbot/bin/dotbot"}
+if ${USE_VAGRANT}; then
+ DOTBOT_EXEC=${DOTBOT_EXEC:-"python /dotbot/bin/dotbot"}
+else
+ DOTBOT_EXEC=${DOTBOT_EXEC:-"/dotbot/bin/dotbot"}
+fi
DOTFILES="/home/$(whoami)/dotfiles"
INSTALL_CONF='install.conf.yaml'
INSTALL_CONF_JSON='install.conf.json'
diff --git a/test/tests/find-python-executable.bash b/test/tests/find-python-executable.bash
index cc46724..d4fa7eb 100644
--- a/test/tests/find-python-executable.bash
+++ b/test/tests/find-python-executable.bash
@@ -1,6 +1,10 @@
test_description='can find python executable with different names'
. '../test-lib.bash'
+if ${USE_VAGRANT}; then
+ DOTBOT_EXEC="/dotbot/bin/dotbot" # revert to calling it as a shell script
+fi
+
# the test machine needs to have a binary named `python`
test_expect_success 'setup' '
mkdir ~/tmp_bin &&
@@ -26,7 +30,7 @@ test_expect_success 'setup 2' '
touch ~/tmp_bin/python &&
chmod +x ~/tmp_bin/python &&
cat >> ~/tmp_bin/python <<EOF
-#!$HOME/tmp_bin/sh
+#!$HOME/tmp_bin/bash
exec $(which python)
EOF
'