Patchwork [2,of,3,v2] run-tests: refactor _checkportrange

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 29, 2015, 5:39 a.m.
Message ID <a12404484af03ddddbd3.1451367599@waste.org>
Download mbox | patch
Permalink /patch/12390/
State Rejected
Delegated to: Yuya Nishihara
Headers show

Comments

timeless@mozdev.org - Dec. 29, 2015, 5:39 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1451364528 0
#      Tue Dec 29 04:48:48 2015 +0000
# Node ID a12404484af03ddddbd326af08ca1217b77ebc13
# Parent  06b5ab5cc75f145c3bb55baae19caa5f9d1856c8
run-tests: refactor _checkportrange

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2005,20 +2005,21 @@ 
         if warned:
             return 80
 
+    def _checkportrange(self, port, portneeded):
+        for idx in xrange(portneeded):
+            if not checkportisavailable(port + idx):
+                return False
+        return True
+
     def _getport(self, count):
         port = self._ports.get(count) # do we have a cached entry?
         if port is None:
             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
-                        break
                 self._portoffset += portneeded
-                if allfree:
+                if self._checkportrange(port, portneeded):
                     break
             self._ports[count] = port
         return port