[PATCH] run-tests: fix get port to try differing ports

timeless at gmail.com timeless at gmail.com
Tue Dec 29 04:32:55 UTC 2015


# HG changeset patch
# User timeless at gmail.com
# Date 1451363438 0
#      Tue Dec 29 04:30:38 2015 +0000
# Node ID 152efdc3654bf96e08e17201392eb769c3a7c322
# Parent  23541bdd1610c08af247f9c8719045cf247ce541
run-tests: fix get port to try differing ports

The code was moving its offset each time through the loop,
but because it failed to update port, the port was not
going to be available...

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2008,11 +2008,11 @@
     def _getport(self, count):
         port = self._ports.get(count) # do we have a cached entry?
         if port is None:
-            port = self.options.port + self._portoffset
             portneeded = 3
             # above 100 tries we just give up and let test reports failure
             for tries in xrange(100):
                 allfree = True
+                port = self.options.port + self._portoffset
                 for idx in xrange(portneeded):
                     if not checkportisavailable(port + idx):
                         allfree = False
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -228,6 +228,19 @@
   [1]
   $ rm test-serve-fail.t
 
+Verify that we can try other ports
+===================================
+  $ hg init inuse
+  $ hg serve -R inuse -p $HGPORT -d --pid-file=blocks.pid
+  $ cat > test-serve-inuse.t <<EOF
+  >   $ hg serve -R `pwd`/inuse -p \$HGPORT -d --pid-file=hg.pid
+  > EOF
+  $ rt test-serve-inuse.t
+  .
+  # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
+  $ cat blocks.pid >> $DAEMON_PIDS
+  $ rm test-serve-inuse.t
+
 Running In Debug Mode
 ======================
 


More information about the Mercurial-devel mailing list