[PATCH stable] test-extension: fix disabled extension tests for run-tests.py --local

Brodie Rao dackze at gmail.com
Fri Mar 5 16:38:40 CST 2010


# HG changeset patch
# User Brodie Rao <me+hg at dackz.net>
# Date 1267828682 18000
# Branch stable
# Node ID 933a6ddd8b21e423c690c1313f84cbbc93459606
# Parent  5faf3566c96dbfdfcf5b817d9ebeb956602fce8a
test-extension: fix disabled extension tests for run-tests.py --local

One test that requires inserting a broken extension into hgext does this
by modifying PYTHONPATH. This doesn't work when run with --local because
the 'hg' script being used is in the same directory as the local hgext.

Instead of modifying PYTHONPATH, a secondary extension is enabled using
--config that inserts the dummy hgext at the beginning of sys.path,
before the script's path.

diff --git a/tests/test-extension b/tests/test-extension
--- a/tests/test-extension
+++ b/tests/test-extension
@@ -168,12 +168,13 @@ echo > hgext/__init__.py
 cat > hgext/broken.py <<EOF
 "broken extension'
 EOF
-TMPPYTHONPATH="$PYTHONPATH"
-PYTHONPATH="`pwd`:$PYTHONPATH"
-export PYTHONPATH
-hg help broken
-hg help foo > /dev/null
-PYTHONPATH="$TMPPYTHONPATH"
-export PYTHONPATH
+cat > path.py <<EOF
+import os, sys
+sys.path.insert(0, os.environ['HGEXTPATH'])
+EOF
+HGEXTPATH=`pwd`
+export HGEXTPATH
+hg --config extensions.path=./path.py help broken
+hg --config extensions.path=./path.py help foo > /dev/null
 
 exit 0


More information about the Mercurial-devel mailing list