Patchwork D11044: run-tests: always define a custom-bin directory

login
register
mail settings
Submitter phabricator
Date July 10, 2021, 12:38 a.m.
Message ID <differential-rev-PHID-DREV-fvzsb6qiypqptj7fnu6l-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49358/
State Superseded
Headers show

Comments

phabricator - July 10, 2021, 12:38 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We are always generating `python` / `python3` executable and we will often
  generate a `hg` executable (soon). So let's make it here always.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11044

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -3033,7 +3033,8 @@ 
         self._hgtmp = None
         self._installdir = None
         self._bindir = None
-        self._tmpbindir = None
+        # a place for run-tests.py to generate executable it needs
+        self._custom_bin_dir = None
         self._pythondir = None
         # True if we had to infer the pythondir from --with-hg
         self._pythondir_inferred = False
@@ -3123,14 +3124,15 @@ 
 
         self._hgtmp = osenvironb[b'HGTMP'] = os.path.realpath(tmpdir)
 
+        self._custom_bin_dir = os.path.join(self._hgtmp, b'custom-bin')
+        os.makedirs(self._custom_bin_dir)
+
         if self.options.with_hg:
             self._installdir = None
             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)
 
             normbin = os.path.normpath(os.path.abspath(whg))
             normbin = normbin.replace(_sys2bytes(os.sep), b'/')
@@ -3158,7 +3160,6 @@ 
             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")
 
         # Force the use of hg.exe instead of relying on MSYS to recognize hg is
@@ -3221,8 +3222,7 @@ 
             path.insert(1, rhgbindir)
         if self._testdir != runtestdir:
             path = [self._testdir] + path
-        if self._tmpbindir != self._bindir:
-            path = [self._tmpbindir] + path
+        path = [self._custom_bin_dir] + path
         osenvironb[b"PATH"] = sepb.join(path)
 
         # Include TESTDIR in PYTHONPATH so that out-of-tree extensions
@@ -3565,7 +3565,7 @@ 
             msg %= sysexecutable
             vlog(msg)
             for pyexename in pyexe_names:
-                mypython = os.path.join(self._tmpbindir, pyexename)
+                mypython = os.path.join(self._custom_bin_dir, pyexename)
                 try:
                     if os.readlink(mypython) == sysexecutable:
                         continue