File tree Expand file tree Collapse file tree 2 files changed +59
-3
lines changed
Expand file tree Collapse file tree 2 files changed +59
-3
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ # set -x
4+
5+ test_dir=$( dirname $0 )
6+ # source "$test_dir/../virtualenvwrapper.sh"
7+
8+ export SCRATCH_DIR=" ${TMPDIR:-/ tmp} /test_scratch_dir"
9+
10+ oneTimeSetUp () {
11+ rm -rf " $SCRATCH_DIR "
12+ mkdir -p " $SCRATCH_DIR "
13+ }
14+
15+ oneTimeTearDown () {
16+ rm -rf " $SCRATCH_DIR "
17+ }
18+
19+ setUp () {
20+ echo
21+ unset VIRTUALENVWRAPPER_TMPDIR
22+ }
23+
24+ test_unset_tmpdir () {
25+ old_tmpdir=" $TMPDIR "
26+ unset TMPDIR
27+ source " $test_dir /../virtualenvwrapper.sh"
28+ export TMPDIR=" $old_tmpdir "
29+ assertSame " $VIRTUALENVWRAPPER_TMPDIR " " /tmp"
30+ }
31+
32+ test_set_tmpdir () {
33+ old_tmpdir=" $TMPDIR "
34+ export TMPDIR=" $SCRATCH_DIR "
35+ source " $test_dir /../virtualenvwrapper.sh"
36+ export TMPDIR=" $old_tmpdir "
37+ assertSame " $VIRTUALENVWRAPPER_TMPDIR " " $SCRATCH_DIR "
38+ }
39+
40+ test_set_virtualenvwrapper_tmpdir () {
41+ VIRTUALENVWRAPPER_TMPDIR=" $SCRATCH_DIR "
42+ source " $test_dir /../virtualenvwrapper.sh"
43+ assertSame " $VIRTUALENVWRAPPER_TMPDIR " " $SCRATCH_DIR "
44+ }
45+
46+ . " $test_dir /shunit2"
Original file line number Diff line number Diff line change @@ -59,6 +59,16 @@ VIRTUALENVWRAPPER_PYTHON="$(which python)"
5959WORKON_HOME=$( " $VIRTUALENVWRAPPER_PYTHON " -c " import os; print os.path.abspath(os.path.expandvars(os.path.expanduser(\" $WORKON_HOME \" )))" )
6060export WORKON_HOME
6161
62+ # Make sure we have a location for temporary files
63+ if [ " $VIRTUALENVWRAPPER_TMPDIR " = " " ]
64+ then
65+ VIRTUALENVWRAPPER_TMPDIR=" $TMPDIR "
66+ if [ " $VIRTUALENVWRAPPER_TMPDIR " = " " ]
67+ then
68+ VIRTUALENVWRAPPER_TMPDIR=" /tmp"
69+ fi
70+ fi
71+
6272# Verify that the WORKON_HOME directory exists
6373function virtualenvwrapper_verify_workon_home () {
6474 if [ ! -d " $WORKON_HOME " ]
@@ -77,9 +87,9 @@ function virtualenvwrapper_run_hook () {
7787 " $VIRTUALENVWRAPPER_PYTHON " -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION " $@ "
7888 # Now anything that wants to run inside this shell
7989 " $VIRTUALENVWRAPPER_PYTHON " -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \
80- --source " $@ " >> $TMPDIR /$$ .hook
81- source $TMPDIR /$$ .hook
82- rm -f $TMPDIR /$$ .hook
90+ --source " $@ " >> $VIRTUALENVWRAPPER_TMPDIR /$$ .hook
91+ source $VIRTUALENVWRAPPER_TMPDIR /$$ .hook
92+ rm -f $VIRTUALENVWRAPPER_TMPDIR /$$ .hook
8393}
8494
8595# Set up virtualenvwrapper properly
You can’t perform that action at this time.
0 commit comments