Patchwork run-tests.py: work when --with-hg is set to system hg

login
register
mail settings
Submitter Siddharth Agarwal
Date Feb. 20, 2014, 5:44 a.m.
Message ID <f3a8a99e4bc76dcd64cb.1392875063@dev1738.prn1.facebook.com>
Download mbox | patch
Permalink /patch/3718/
State Accepted
Headers show

Comments

Siddharth Agarwal - Feb. 20, 2014, 5:44 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1392874334 28800
#      Wed Feb 19 21:32:14 2014 -0800
# Node ID f3a8a99e4bc76dcd64cb077f3c93cfe60682da75
# Parent  87e52e6425625ea4f7645cfe2fc491a21f9a6b51
run-tests.py: work when --with-hg is set to system hg

Previously we'd always assume that --with-hg is a script in a user directory,
and would write out a 'python' symlink to the same location. That didn't work
if --with-hg was set to a system installation of hg, e.g. /usr/bin/hg.

Introduce a TMPBINDIR directory which is used to write out the python symlink.
Matt Mackall - Feb. 21, 2014, 11:30 p.m.
On Wed, 2014-02-19 at 21:44 -0800, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1392874334 28800
> #      Wed Feb 19 21:32:14 2014 -0800
> # Node ID f3a8a99e4bc76dcd64cb077f3c93cfe60682da75
> # Parent  87e52e6425625ea4f7645cfe2fc491a21f9a6b51
> run-tests.py: work when --with-hg is set to system hg

Queued for default, thanks.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -434,7 +434,7 @@ 
     if getattr(os, 'symlink', None):
         vlog("# Making python executable in test path a symlink to '%s'" %
              sys.executable)
-        mypython = os.path.join(BINDIR, pyexename)
+        mypython = os.path.join(TMPBINDIR, pyexename)
         try:
             if os.readlink(mypython) == sys.executable:
                 return
@@ -1215,7 +1215,7 @@ 
         # we do the randomness ourself to know what seed is used
         os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32))
 
-    global TESTDIR, HGTMP, INST, BINDIR, PYTHONDIR, COVERAGE_FILE
+    global TESTDIR, HGTMP, INST, BINDIR, TMPBINDIR, PYTHONDIR, COVERAGE_FILE
     TESTDIR = os.environ["TESTDIR"] = os.getcwd()
     if options.tmpdir:
         options.keep_tmpdir = True
@@ -1244,6 +1244,8 @@ 
     if options.with_hg:
         INST = None
         BINDIR = os.path.dirname(os.path.realpath(options.with_hg))
+        TMPBINDIR = os.path.join(HGTMP, 'install', 'bin')
+        os.makedirs(TMPBINDIR)
 
         # This looks redundant with how Python initializes sys.path from
         # the location of the script being executed.  Needed because the
@@ -1254,12 +1256,15 @@ 
     else:
         INST = os.path.join(HGTMP, "install")
         BINDIR = os.environ["BINDIR"] = os.path.join(INST, "bin")
+        TMPBINDIR = BINDIR
         PYTHONDIR = os.path.join(INST, "lib", "python")
 
     os.environ["BINDIR"] = BINDIR
     os.environ["PYTHON"] = PYTHON
 
     path = [BINDIR] + os.environ["PATH"].split(os.pathsep)
+    if TMPBINDIR != BINDIR:
+        path = [TMPBINDIR] + path
     os.environ["PATH"] = os.pathsep.join(path)
 
     # Include TESTDIR in PYTHONPATH so that out-of-tree extensions