Skip to content

Commit

Permalink
Fix bug in test harness
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
anishathalye committed Mar 28, 2018
1 parent b7022f4 commit a517c4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion test/test-lib.bash
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
6 changes: 5 additions & 1 deletion test/tests/find-python-executable.bash
Original file line number Diff line number Diff line change
@@ -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 &&
Expand All @@ -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
'
Expand Down

0 comments on commit a517c4c

Please sign in to comment.