[PATCH 1 of 5] run-tests.py: execute hghave by the path relative to run-tests.py

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Jul 2 17:01:04 CDT 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1435874163 -32400
#      Fri Jul 03 06:56:03 2015 +0900
# Node ID 4e720dd1ec4ec6edf7f9770360ec9471bd4b862f
# Parent  84518051bc3b851f736872df045d662de548b3c9
run-tests.py: execute hghave by the path relative to run-tests.py

Before this patch, `run-tests.py` executes `hghave` by the path
relative to `TESTDIR` (= cwd of `run-tests.py` running).

This prevents third party tools for Mercurial from running
`run-tests.py`, which is placed in `tests` of Mercurial source tree,
in `tests` of own source tree. In such cases, `TESTDIR` refers the
latter `tests`, and `hghave` doesn't exist in it.

This is a one of preparations for issue4677.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -902,7 +902,8 @@
 
     def _hghave(self, reqs):
         # TODO do something smarter when all other uses of hghave are gone.
-        tdir = self._testdir.replace(b'\\', b'/')
+        runtestdir = os.path.abspath(os.path.dirname(_bytespath(__file__)))
+        tdir = runtestdir.replace(b'\\', b'/')
         proc = Popen4(b'%s -c "%s/hghave %s"' %
                       (self._shell, tdir, b' '.join(reqs)),
                       self._testtmp, 0, self._getenv())
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -566,3 +566,20 @@
 
   $ rm -f test-glob-backslash.t
 
+Test reusability for third party tools
+======================================
+
+  $ mkdir "$TESTTMP"/anothertests
+  $ cd "$TESTTMP"/anothertests
+
+test that `run-tests.py` can execute hghave, even if it runs not in
+Mercurial source tree.
+
+  $ cat > test-hghave.t <<EOF
+  > #require true
+  >   $ echo foo
+  >   foo
+  > EOF
+  $ run-tests.py test-hghave.t
+  .
+  # Ran 1 tests, 0 skipped, 0 warned, 0 failed.


More information about the Mercurial-devel mailing list