[PATCH 1 of 5] run-tests: include testdir in $PATH so tests easily can use helper tools

Mads Kiilerich mads at kiilerich.com
Wed Jan 14 23:24:36 UTC 2015


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1421194526 -3600
#      Wed Jan 14 01:15:26 2015 +0100
# Node ID 1b43d00b9a2551b3e70b09562e27c50c0cb6decd
# Parent  71402bb8d8b274d82169cf26253e38ef793794f5
run-tests: include testdir in $PATH so tests easily can use helper tools

The testdir is already added to $PYTHONPATH - I think it makes sense and is
convenient to add it to $PATH too.

The following binaries are invoked from tests using full path with $TESTDIR/ -
they can now be used without specifying path:
  dumbhttp.py
  dummyssh
  filterpyflakes.py
  generate-working-copy-states.py
  get-with-headers.py
  hghave
  histedit-helpers.sh
  killdaemons.py
  md5sum.py
  notcapable
  printenv.py
  readlink.py
  revlog-formatv0.py
  run-tests.py
  svn-safe-append.py
  svnxml.py
  tinyproxy.py

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1644,7 +1644,8 @@ class TestRunner(object):
         os.environ["BINDIR"] = self._bindir
         os.environ["PYTHON"] = PYTHON
 
-        path = [self._bindir] + os.environ["PATH"].split(os.pathsep)
+        runtestdir = os.path.abspath(os.path.dirname(__file__))
+        path = [self._bindir, runtestdir] + os.environ["PATH"].split(os.pathsep)
         if self._tmpbindir != self._bindir:
             path = [self._tmpbindir] + path
         os.environ["PATH"] = os.pathsep.join(path)
@@ -1653,8 +1654,7 @@ class TestRunner(object):
         # can run .../tests/run-tests.py test-foo where test-foo
         # adds an extension to HGRC. Also include run-test.py directory to
         # import modules like heredoctest.
-        pypath = [self._pythondir, self._testdir,
-                  os.path.abspath(os.path.dirname(__file__))]
+        pypath = [self._pythondir, self._testdir, runtestdir]
         # We have to augment PYTHONPATH, rather than simply replacing
         # it, in case external libraries are only available via current
         # PYTHONPATH.  (In particular, the Subversion bindings on OS X


More information about the Mercurial-devel mailing list