Commits

Doug Hellmann committed a6cd415

more test refinements

Comments (0)

Files changed (13)

+2010-05-22  Doug Hellmann  <dhellmann@racemi.com>
+
+	* tests/test_cp.sh: Clarify some of the tests by breaking up,
+	renaming, and rewriting some functions.
+
+	* Makefile (PYTHON26): If we're in a virtualenv when the tests
+	start, use a hard-coded path to the binary to get the global
+	version.
+
 2010-05-18  Doug Hellmann  <dhellmann@racemi.com>
 
 	* virtualenvwrapper.sh (virtualenvwrapper_tempfile): Use a trap to
 
 # Locations of Python interpreter binaries
 PYTHON27=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.7b1/bin/python2.7
+ifeq ($VIRTUAL_ENV,)
 PYTHON26=$(shell which python2.6)
+else
+PYTHON26=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
+endif
 PYTHON25=/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
 PYTHON24=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.4.6/bin/python2.4
 
 	@echo "installwebsite - deploy web version of docs"
 	@echo "develop        - install development version"
 	@echo "test           - run the test suite"
-	@echo "test-quick     - run the test suite for bash and one version of Python"
+	@echo "test-quick     - run the test suite for bash and one version of Python ($(PYTHON26))"
 
 
 .PHONY: sdist
 
 #set -x
 
-test_dir=$(dirname $0)
+test_dir=$(cd $(dirname $0) && pwd)
 
-export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
+export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"

tests/test_add2virtualenv.sh

 
 #set -x
 
-test_dir=$(dirname $0)
+test_dir=$(cd $(dirname $0) && pwd)
 
-export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
+export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"
 
 #set -x
 
-test_dir=$(dirname $0)
+test_dir=$(cd $(dirname $0) && pwd)
 
-export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
+export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"
 
 #set -x
 
-test_dir=$(dirname $0)
+test_dir=$(cd $(dirname $0) && pwd)
 
-export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
+export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
 unset HOOK_VERBOSE_OPTION
 
     rm -rf "$WORKON_HOME"
 }
 
-test_cpvirtualenv () {
+test_new_env_activated () {
     mkvirtualenv "source"
     (cd tests/testpackage && python setup.py install) >/dev/null 2>&1
     cpvirtualenv "source" "destination"
-    assertSame "destination" $(basename "$VIRTUAL_ENV")
     rmvirtualenv "source"
     testscript="$(which testscript.py)"
     assertTrue "Environment test script not found in path" "[ $WORKON_HOME/destination/bin/testscript.py -ef $testscript ]"
     testscriptcontent="$(cat $testscript)"
-    assertTrue "No cpvirtualenvtest in $/testscriptcontent" "echo $testscriptcontent | grep cpvirtualenvtest"
+    assertTrue "No cpvirtualenvtest in $testscriptcontent" "echo $testscriptcontent | grep cpvirtualenvtest"
     assertTrue virtualenvwrapper_verify_active_environment
+}
+
+test_virtual_env_variable () {
+    mkvirtualenv "source"
+    cpvirtualenv "source" "destination"
     assertSame "Wrong virtualenv name" "destination" $(basename "$VIRTUAL_ENV")
+    assertTrue "$WORKON_HOME not in $VIRTUAL_ENV" "echo $VIRTUAL_ENV | grep -q $WORKON_HOME"
 }
 
-test_cprelocatablevirtualenv () {
+test_source_relocatable () {
     mkvirtualenv "source"
     (cd tests/testpackage && python setup.py install) >/dev/null 2>&1
     assertTrue "virtualenv --relocatable \"$WORKON_HOME/source\""
     assertSame "Wrong virtualenv name" "destination" $(basename "$VIRTUAL_ENV")
 }
 
-test_cp_notexists () {
+test_source_does_not_exist () {
     out="$(cpvirtualenv virtualenvthatdoesntexist foo)"
     assertSame "$out" "virtualenvthatdoesntexist virtualenv doesn't exist"
 }

tests/test_deactivate.sh

 
 #set -x
 
-test_dir=$(dirname $0)
+test_dir=$(cd $(dirname $0) && pwd)
 
-export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
+export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"
 
 #set -x
 
-test_dir=$(dirname $0)
+test_dir=$(cd $(dirname $0) && pwd)
 
-export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
+export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"

tests/test_mkvirtualenv.sh

 
 #set -x
 
-test_dir=$(dirname $0)
-export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
+test_dir=$(cd $(dirname $0) && pwd)
+
+export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"

tests/test_rmvirtualenv.sh

 
 #set -x
 
-test_dir=$(dirname $0)
+test_dir=$(cd $(dirname $0) && pwd)
 
-export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
+export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"

tests/test_run_hook.sh

 
 #set -x
 
-export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
+test_dir=$(cd $(dirname $0) && pwd)
 
-test_dir=$(dirname $0)
+export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"

tests/test_tempfile.sh

 
 #set -x
 
-test_dir=$(dirname $0)
+test_dir=$(cd $(dirname $0) && pwd)
+
+export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
-export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
 export HOOK_VERBOSE_OPTION=-v
 
 oneTimeSetUp() {

tests/test_workon.sh

 
 #set -x
 
-test_dir=$(dirname $0)
+test_dir=$(cd $(dirname $0) && pwd)
 
-export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
+export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"
     mkdir -p "$WORKON_HOME"
     source "$test_dir/../virtualenvwrapper.sh"
     mkvirtualenv "env1"
+    mkvirtualenv "env2"
+    deactivate >/dev/null 2>&1 
 }
 
 oneTimeTearDown() {
     rm -f "$test_dir/catch_output"
 }
 
+tearDown () {
+    deactivate >/dev/null 2>&1 
+}
+
 test_workon () {
     workon env1
     assertTrue virtualenvwrapper_verify_active_environment
 test_workon_activate_hooks () {
     for t in pre post
     do
+        echo "#!/bin/bash" > "$WORKON_HOME/${t}activate"
         echo "echo GLOBAL ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/${t}activate"
         chmod +x "$WORKON_HOME/${t}activate"
+        echo "#!/bin/bash" > "$WORKON_HOME/env2/bin/${t}activate"
         echo "echo ENV ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/env1/bin/${t}activate"
         chmod +x "$WORKON_HOME/env1/bin/${t}activate"
     done
     mkdir "$WORKON_HOME/not_env"
     (cd "$WORKON_HOME"; ln -s env1 link_env)
     envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ')
-    assertSame "env1 link_env " "$envs"
+    assertSame "env1 env2 link_env " "$envs"
     rmdir "$WORKON_HOME/not_env"
     rm -f "$WORKON_HOME/link_env"
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.