Patchwork D10942: run-tests: avoid an early return

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

Comments

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

REVISION SUMMARY
  To fix the "python3 pointing to python2" we will also need to create a "python"
  pointer. So we will need to create multiple pointer. So we need to stop using
  early return.
  
  We replace the early return with a loop and a continue, since the next
  changeset will introduce that loop anyway.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -3540,22 +3540,23 @@ 
             msg = "# Making python executable in test path a symlink to '%s'"
             msg %= sysexecutable
             vlog(msg)
-            mypython = os.path.join(self._tmpbindir, pyexename)
-            try:
-                if os.readlink(mypython) == sysexecutable:
-                    return
-                os.unlink(mypython)
-            except OSError as err:
-                if err.errno != errno.ENOENT:
-                    raise
-            if self._findprogram(pyexename) != sysexecutable:
+            for pyexename in [pyexename]:
+                mypython = os.path.join(self._tmpbindir, pyexename)
                 try:
-                    os.symlink(sysexecutable, mypython)
-                    self._createdfiles.append(mypython)
+                    if os.readlink(mypython) == sysexecutable:
+                        continue
+                    os.unlink(mypython)
                 except OSError as err:
-                    # child processes may race, which is harmless
-                    if err.errno != errno.EEXIST:
+                    if err.errno != errno.ENOENT:
                         raise
+                if self._findprogram(pyexename) != sysexecutable:
+                    try:
+                        os.symlink(sysexecutable, mypython)
+                        self._createdfiles.append(mypython)
+                    except OSError as err:
+                        # child processes may race, which is harmless
+                        if err.errno != errno.EEXIST:
+                            raise
         else:
             # Windows doesn't have `python3.exe`, and MSYS cannot understand the
             # reparse point with that name provided by Microsoft.  Create a