Commits

Doug Hellmann committed b54289d

fix tests to work under ksh on ubuntu 10.10 by using alternate syntax for capturing messages sent to stderr

  • Participants
  • Parent commits f53aa6c

Comments (0)

Files changed (7)

 test_virtualenvwrapper_verify_workon_home_missing_dir() {
     old_home="$WORKON_HOME"
     WORKON_HOME="$WORKON_HOME/not_there"
-    output=$(virtualenvwrapper_verify_workon_home 2>&1)
+    assertTrue "Directory already exists" "[ ! -d \"$WORKON_HOME\" ]"
+    virtualenvwrapper_verify_workon_home >"$old_home/output" 2>&1
+    output=$(cat "$old_home/output")
     assertSame "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." "$output"
-    assertTrue "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home
+    WORKON_HOME="$old_home"
+}
+
+test_virtualenvwrapper_verify_workon_home_missing_dir_quiet() {
+    old_home="$WORKON_HOME"
+    WORKON_HOME="$WORKON_HOME/not_there_quiet"
+    assertTrue "Directory already exists" "[ ! -d \"$WORKON_HOME\" ]"
+    output=$(virtualenvwrapper_verify_workon_home -q 2>&1)
+    assertSame "" "$output"
     WORKON_HOME="$old_home"
 }
 
 test_cdvirtualenv_no_workon_home () {
     old_home="$WORKON_HOME"
     export WORKON_HOME="$WORKON_HOME/not_there"
-    output=$(cdvirtualenv 2>&1)
+    cdvirtualenv >"$old_home/output" 2>&1
+    output=$(cat "$old_home/output")
     assertTrue "Did not see expected message" "echo $output | grep 'does not exist'"
     WORKON_HOME="$old_home"
 }
 test_no_workon_home () {
     old_home="$WORKON_HOME"
     export WORKON_HOME="$WORKON_HOME/not_there"
-    output=`lssitepackages should_not_be_created 2>&1`
+    lssitepackages >"$old_home/output" 2>&1
+    output=$(cat "$old_home/output")
     assertTrue "Did not see expected message" "echo $output | grep 'does not exist'"
     WORKON_HOME="$old_home"
 }

tests/test_mkvirtualenv.sh

 test_no_workon_home () {
     old_home="$WORKON_HOME"
     export WORKON_HOME="$WORKON_HOME/not_there"
-    output=`mkvirtualenv should_not_be_created 2>&1`
+    mkvirtualenv should_be_created >"$old_home/output" 2>&1
+    output=$(cat "$old_home/output")
     assertTrue "Did not see expected message" "echo $output | grep 'does not exist'"
+    assertTrue "Did not create environment" "[ -d \"$WORKON_HOME/should_be_created\" ]"
     WORKON_HOME="$old_home"
 }
 

tests/test_rmvirtualenv.sh

     mkvirtualenv "deleteme"
     deactivate
     alias rm='rm -i'
-    set -x
     rmvirtualenv "deleteme"
-    set +x
     unalias rm
 }
 
 test_no_workon_home () {
     old_home="$WORKON_HOME"
     export WORKON_HOME="$WORKON_HOME/not_there"
-    output=`rmvirtualenv should_not_be_created 2>&1`
+    rmvirtualenv should_not_be_created >"$old_home/output" 2>&1
+    output=$(cat "$old_home/output")
     assertTrue "Did not see expected message" "echo $output | grep 'does not exist'"
     WORKON_HOME="$old_home"
 }

tests/test_workon.sh

 test_no_workon_home () {
     old_home="$WORKON_HOME"
     export WORKON_HOME="$WORKON_HOME/not_there"
-    output=`workon should_not_be_created 2>&1`
+    workon should_not_be_created >"$old_home/output" 2>&1
+    output=$(cat "$old_home/output")
     assertTrue "Did not see expected message" "echo $output | grep 'does not exist'"
     WORKON_HOME="$old_home"
 }

virtualenvwrapper.sh

 # seperate from creating the files in it because this used to just error
 # and maybe other things rely on the dir existing before that happens.
 virtualenvwrapper_verify_workon_home () {
+    RC=0
     if [ ! -d "$WORKON_HOME" ]
     then
-        [ "$1" != "-q" ] && echo "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2
-        mkdir $WORKON_HOME
+        if [ "$1" != "-q" ]
+        then
+            echo "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2
+        fi
+        mkdir -p $WORKON_HOME
+        RC=$?
     fi
-    return 0
+    return $RC
 }
 
 #HOOK_VERBOSE_OPTION="-q"