Commits

Doug Hellmann committed 534f028

changes to make the tests run on my linux host

Comments (0)

Files changed (5)

 2010-05-16  Doug Hellmann  <dhellmann@racemi.com>
 
+	* Makefile (PYTHON26): Use which to find python2.6, the default
+	interpreter, so we can run the tests as "make test-quick" on other
+	hosts.
+
+	* tests/test_tempfile.sh (test_tempfile): Normalize the paths so
+	we don't depend on the value of TMPDIR or behavior of dirname.
+
+	* tests/test_cd.sh: Make sure the virtualenv from the caller does
+	not influence test behaviors by establishing our own virtualenv
+	locally.
+
 	* virtualenvwrapper/hook_loader.py (main): Add more debug logging
 	to try to narrow down the tempfile issue (#35).
+	(run_hooks): Insert a comment into the output file to show which
+	hook we are running.
 
 	* virtualenvwrapper.sh (virtualenvwrapper_run_hook): Add more
 	debugging error reporting to try to narrow down the tempfile
 
 # Locations of Python interpreter binaries
 PYTHON27=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.7b1/bin/python2.7
-PYTHON26=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
+PYTHON26=$(shell which python2.6)
 PYTHON25=/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
 PYTHON24=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.4.6/bin/python2.4
 
 	 		echo '********************************************************************************' ; \
 			echo "Running $$test_script with $(TEST_SHELL) under Python $(basename $$py_bin)" ; \
 			echo ; \
-			VIRTUALENVWRAPPER_PYTHON=$$TMPDIR/virtualenvwrapper-test-env/bin/python SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \
+			HOOK_VERBOSE_OPTION=-v VIRTUALENVWRAPPER_PYTHON=$$TMPDIR/virtualenvwrapper-test-env/bin/python SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \
 			echo ; \
 		done \
 	done
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"
     mkdir -p "$WORKON_HOME"
+    unset VIRTUAL_ENV
     source "$test_dir/../virtualenvwrapper.sh"
+    mkvirtualenv cd-test
+    deactivate
 }
 
 oneTimeTearDown() {
 setUp () {
     echo
     rm -f "$test_dir/catch_output"
+    workon cd-test
+}
+
+tearDown () {
+    deactivate
 }
 
 test_cdvirtual() {

tests/test_tempfile.sh

 
 test_tempfile () {
     filename=$(virtualenvwrapper_tempfile hook)
+    assertTrue "Filename is empty" "[ ! -z \"$filename\" ]"
     rm -f $filename
-    assertSame "TMPDIR and path not the same for $filename." "$TMPDIR" "$(dirname $filename)/"
+    comparable_tmpdir=$(echo $TMPDIR | sed 's|/$||')
+    comparable_dirname=$(dirname $filename | sed 's|/$||')
+    assertSame "TMPDIR and path not the same for $filename" "$comparable_tmpdir" "$comparable_dirname"
     assertTrue "virtualenvwrapper-hook not in filename." "echo $filename | grep virtualenvwrapper-hook"
 }
 

virtualenvwrapper/hook_loader.py

             # be run in the calling shell.
             contents = (plugin(args[1:]) or '').strip()
             if contents:
+                output.write('# %s\n' % ep.name)
                 output.write(contents)
                 output.write("\n")
         else: