Skip to content

Commit 92d2655

Browse files
committed
Check that required test shells are available ahead of running tests. This avoids accidentally running tests with /bin/sh (dash) on Debian, which eventually deletes the ~/.virtualenvs directory. (Whoops.)
1 parent c680921 commit 92d2655

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

tests/run_tests

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ then
2121
fi
2222
fi
2323

24+
# Make sure the test shells exist before proceeding, otherwise tests are
25+
# going to fail later.
26+
missing_shells=""
27+
test_shells=""
28+
for shell in bash ksh zsh
29+
do
30+
if test_shell=$(which $shell); then
31+
test_shells="$test_shells $test_shell"
32+
else
33+
missing_shells="$missing_shells $shell"
34+
fi
35+
done
36+
if [ -n "$missing_shells" ]
37+
then
38+
echo "Couldn't find the following shells: $missing_shells" 1>&2
39+
exit 1
40+
fi
41+
2442
# Force the tox virtualenv to be active.
2543
#
2644
# Since this script runs from within a separate shell created by tox,
@@ -49,13 +67,13 @@ unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS
4967
for test_script in $scripts
5068
do
5169

52-
for test_shell in bash ksh zsh
70+
for test_shell in $test_shells
5371
do
5472
test_shell_opts=
55-
if [ $test_shell = "zsh" ]; then
56-
test_shell_opts="-o shwordsplit"
57-
fi
58-
export test_shell=$(which $test_shell)
73+
case /$test_shell in
74+
*/zsh) test_shell_opts="-o shwordsplit" ;;
75+
esac
76+
export test_shell
5977

6078
echo
6179
echo '********************************************************************************'

0 commit comments

Comments
 (0)