Patchwork [1,of,2,STABLE] run-tests: fix conditional when tests are run outside of `tests`

login
register
mail settings
Submitter Pierre-Yves David
Date March 10, 2020, 5:17 p.m.
Message ID <7621c3b5191c951e974c.1583860641@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/45671/
State Accepted
Headers show

Comments

Pierre-Yves David - March 10, 2020, 5:17 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1583855222 -3600
#      Tue Mar 10 16:47:02 2020 +0100
# Branch stable
# Node ID 7621c3b5191c951e974c31147b559101c0e9bf48
# Parent  9803b374389a408dabdd4e3810ed7217ac0186a1
# EXP-Topic fix-hghave
# Available At https://dev.heptapod.net/octobus/mercurial-devel/
#              hg pull https://dev.heptapod.net/octobus/mercurial-devel/ -r 7621c3b5191c
run-tests: fix conditional when tests are run outside of `tests`

The logic to find `hghave` was using `__file__` but… non absolute path in
`__file__` gets wrong as soon as we change directory (thanks python… you are
being helpful). The rest of the `run-tests.py` code already deal with this
fine. We simply reuse the `RUNTESTDIR` variable to fix it.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1626,7 +1626,7 @@  class TTest(Test):
             return self._have.get(allreqs)
 
         # TODO do something smarter when all other uses of hghave are gone.
-        runtestdir = os.path.abspath(os.path.dirname(_bytespath(__file__)))
+        runtestdir = osenvironb[b'RUNTESTDIR']
         tdir = runtestdir.replace(b'\\', b'/')
         proc = Popen4(
             b'%s -c "%s/hghave %s"' % (self._shell, tdir, allreqs),