From patchwork Mon Jan 18 06:45:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D9816: run-tests: catch a Windows specific error when testing for a free socket From: phabricator X-Patchwork-Id: 48126 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 18 Jan 2021 06:45:45 +0000 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 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,