[PATCH] run-tests.py: skip test if HGPORT(s) already in use

Mads Kiilerich mads at kiilerich.com
Mon Feb 8 01:59:24 UTC 2010


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1265594348 -3600
# Node ID 42f640fc8330af311b8ba182be6648b061ca0fe1
# Parent  a5576908b5896b4ff04fd836252f225b5a4027b6
run-tests.py: skip test if HGPORT(s) already in use

Ports might be in TIME_WAIT, but if they accept connections then
something is wrong.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -52,6 +52,7 @@
 import sys
 import tempfile
 import time
+import socket
 
 closefds = os.name == 'posix'
 def Popen4(cmd, bufsize=-1):
@@ -563,6 +564,17 @@
             return skip("not executable")
         cmd = '"%s"' % testpath
 
+    if "HGPORT" in file(testpath).read():
+        for i in xrange(3):
+            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+            try:
+                s.connect(('', options.port + i))
+            except socket.error:
+                s.close()
+                continue
+            s.close()
+            return skip("port *:%s already in use" % (options.port + i))
+
     if options.timeout > 0:
         signal.alarm(options.timeout)
 



More information about the Mercurial-devel mailing list