Patchwork D10692: run-tests: ignore PermissionError when checking available ports

login
register
mail settings
Submitter phabricator
Date May 7, 2021, 4:02 a.m.
Message ID <differential-rev-PHID-DREV-jrjuyamtnbpu3lznizft-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49012/
State New
Headers show

Comments

phabricator - May 7, 2021, 4:02 a.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I'm not sure what this is, but I'm getting it occasionally when running in WSL.
  When it was raised, none of the tests could run.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/run-tests.py
  tests/test-check-pyflakes.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-check-pyflakes.t b/tests/test-check-pyflakes.t
--- a/tests/test-check-pyflakes.t
+++ b/tests/test-check-pyflakes.t
@@ -23,4 +23,5 @@ 
   mercurial/hgweb/server.py:*:* undefined name 'reload' (glob) (?)
   mercurial/util.py:*:* undefined name 'file' (glob) (?)
   mercurial/encoding.py:*:* undefined name 'localstr' (glob) (?)
+  tests/run-tests.py:*:* undefined name 'PermissionError' (glob) (?)
   
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -262,7 +262,13 @@ 
     except socket.error as exc:
         if os.name == 'nt' and exc.errno == errno.WSAEACCES:
             return False
-        elif exc.errno not in (
+        elif PYTHON3:
+            # TODO: make a proper exception handler after dropping py2.  This
+            #       works because socket.error is an alias for OSError on py3,
+            #       which is also the baseclass of PermissionError.
+            if isinstance(exc, PermissionError):
+                return False
+        if exc.errno not in (
             errno.EADDRINUSE,
             errno.EADDRNOTAVAIL,
             errno.EPROTONOSUPPORT,