[PATCH] run-tests.py: skip test if HGPORT(s) already in use
Mads Kiilerich
mads at kiilerich.com
Sun Feb 7 19:40:30 CST 2010
Mads Kiilerich wrote, On 02/08/2010 01:53 AM:
> # HG changeset patch
> # User Mads Kiilerich<mads at kiilerich.com>
> # Date 1265590414 -3600
> # Node ID 078c24394e202b8708e5a4af2f8c09d77ce0cfc1
> # Parent a5576908b5896b4ff04fd836252f225b5a4027b6
> run-tests.py: skip test if HGPORT(s) already in use
>
> 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,16 @@
> 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.bind(('', options.port + i))
> + except socket.error, e:
> + return skip("*:%s not available: %s" %
> + (options.port + i, e))
> + s.close()
> +
> if options.timeout> 0:
> signal.alarm(options.timeout)
>
>
This patch causes problems because of TIMEWAIT - but doesn't introduce
it. So I guess it should try to connect instead ...
However, something like this is very convenient when tests leaves
hanging processes and thus causes the following tests to fail. That
seems to happen all the time on solaris 8 right now ...
/Mads
More information about the Mercurial-devel
mailing list