Patchwork [4,of,6,chg-test] run-tests: allow to specify executable of any name by --with-hg

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 12, 2016, 4:12 p.m.
Message ID <07088be4fbe16adfa2ef.1455293557@mimosa>
Download mbox | patch
Permalink /patch/13141/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 12, 2016, 4:12 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1454826099 -32400
#      Sun Feb 07 15:21:39 2016 +0900
# Node ID 07088be4fbe16adfa2efdd9d5dba799909823acc
# Parent  97088e3b2707d37887b9203e78075107aec2b45c
run-tests: allow to specify executable of any name by --with-hg

If the executable is not named as "hg", TTest runner inserts alias. This
way, we can run tests with chg. But it is still warned because the alias
does not always work. We do "$BINDIR"/hg in a few places.
Pierre-Yves David - Feb. 12, 2016, 5:03 p.m.
On 02/12/2016 04:12 PM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1454826099 -32400
> #      Sun Feb 07 15:21:39 2016 +0900
> # Node ID 07088be4fbe16adfa2efdd9d5dba799909823acc
> # Parent  97088e3b2707d37887b9203e78075107aec2b45c
> run-tests: allow to specify executable of any name by --with-hg

I've pushed the first 4 to the clowncopter. Looking at the other two now.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -444,7 +444,7 @@  class Test(unittest.TestCase):
                  debug=False,
                  timeout=defaults['timeout'],
                  startport=defaults['port'], extraconfigopts=None,
-                 py3kwarnings=False, shell=None,
+                 py3kwarnings=False, shell=None, hgcommand=None,
                  slowtimeout=defaults['slowtimeout'],
                  pythondir=None):
         """Create a test from parameters.
@@ -493,6 +493,7 @@  class Test(unittest.TestCase):
         self._py3kwarnings = py3kwarnings
         self._pythondir = pythondir
         self._shell = _bytespath(shell)
+        self._hgcommand = hgcommand or b'hg'
 
         self._aborted = False
         self._daemonpids = []
@@ -992,6 +993,8 @@  class TTest(Test):
 
         if self._debug:
             script.append(b'set -x\n')
+        if self._hgcommand != b'hg':
+            script.append(b'alias hg="%s"\n' % self._hgcommand)
         if os.getenv('MSYSTEM'):
             script.append(b'alias pwd="pwd -W"\n')
 
@@ -1820,6 +1823,7 @@  class TestRunner(object):
         self._pythondir = None
         self._coveragefile = None
         self._createdfiles = []
+        self._hgcommand = None
         self._hgpath = None
         self._portoffset = 0
         self._ports = {}
@@ -1928,6 +1932,7 @@  class TestRunner(object):
             whg = self.options.with_hg
             self._bindir = os.path.dirname(os.path.realpath(whg))
             assert isinstance(self._bindir, bytes)
+            self._hgcommand = os.path.basename(whg)
             self._tmpbindir = os.path.join(self._hgtmp, b'install', b'bin')
             os.makedirs(self._tmpbindir)
 
@@ -1940,6 +1945,7 @@  class TestRunner(object):
         else:
             self._installdir = os.path.join(self._hgtmp, b"install")
             self._bindir = os.path.join(self._installdir, b"bin")
+            self._hgcommand = b'hg'
             self._tmpbindir = self._bindir
             self._pythondir = os.path.join(self._installdir, b"lib", b"python")
 
@@ -2121,6 +2127,7 @@  class TestRunner(object):
                     extraconfigopts=self.options.extra_config_opt,
                     py3kwarnings=self.options.py3k_warnings,
                     shell=self.options.shell,
+                    hgcommand=self._hgcommand,
                     pythondir=self._pythondir)
         t.should_reload = True
         return t