Patchwork run-tests: fix get port to try differing ports

login
register
mail settings
Submitter timeless
Date Dec. 29, 2015, 4:32 a.m.
Message ID <152efdc3654bf96e08e1.1451363575@waste.org>
Download mbox | patch
Permalink /patch/12388/
State Superseded
Headers show

Comments

timeless - Dec. 29, 2015, 4:32 a.m.
# HG changeset patch
# User timeless@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...

Patch

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
 ======================