Patchwork D9816: run-tests: catch a Windows specific error when testing for a free socket

login
register
mail settings
Submitter phabricator
Date Jan. 18, 2021, 6:45 a.m.
Message ID <differential-rev-PHID-DREV-cm2ycbzo4kpjmqm4po6y-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48126/
State Superseded
Headers show

Comments

phabricator - Jan. 18, 2021, 6:45 a.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I'm not sure why this only happens with py3, but this error code doesn't map to
  any of the 3 currently being handled, and kills `run-tests.py` before it can run
  any tests when it happens:
  
    OSError: [WinError 10013] An attempt was made to access a socket in a way
    forbidden by its access permissions
  
  The documentation[1] says this can happen if another process is bound to the
  address with exclusive access.  This seems to keep it happy.
  
  [1] https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS




To: mharbison72, #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
@@ -260,7 +260,9 @@ 
             s.bind(('localhost', port))
         return True
     except socket.error as exc:
-        if exc.errno not in (
+        if os.name == 'nt' and exc.errno == errno.WSAEACCES:
+            return False
+        elif exc.errno not in (
             errno.EADDRINUSE,
             errno.EADDRNOTAVAIL,
             errno.EPROTONOSUPPORT,