Patchwork [1,of,3,v2] run-tests: fix get port to try differing ports

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 29, 2015, 5:39 a.m.
Message ID <06b5ab5cc75f145c3bb5.1451367598@waste.org>
Download mbox | patch
Permalink /patch/12389/
State Accepted
Headers show

Comments

timeless@mozdev.org - Dec. 29, 2015, 5:39 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1451363438 0
#      Tue Dec 29 04:30:38 2015 +0000
# Node ID 06b5ab5cc75f145c3bb55baae19caa5f9d1856c8
# 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...
Yuya Nishihara - Jan. 1, 2016, 7:10 a.m.
On Mon, 28 Dec 2015 23:39:58 -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1451363438 0
> #      Tue Dec 29 04:30:38 2015 +0000
> # Node ID 06b5ab5cc75f145c3bb55baae19caa5f9d1856c8
> # 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

leaks daemon process. Fixed in-flight and pushed this to the clowncopter,
thanks.

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