[PATCH 3 of 4] runtests: set web.ipv6 if we use IPv6

Jun Wu quark at fb.com
Wed Feb 15 19:50:16 EST 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1487205807 28800
#      Wed Feb 15 16:43:27 2017 -0800
# Node ID bacc5256a49b34d07616c1e60e119a74ac721b7a
# Parent  d223c3d57e14f22c18030166b83e2da9143fdf67
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r bacc5256a49b
runtests: set web.ipv6 if we use IPv6

As explained by the previous patch, we need to set "web.ipv6=True" if we
decide to use IPv6. Otherwise "hg serve" will still try to listen on IPv4.

This patch makes it so by appending web.ipv6 to "extra configs".

This patch was tested in a Linux system with IPv6, by the following steps:

  1. Change hgweb/server.py temporarily to write a file if
     IPv6HTTPServer.__init__ is called.
  2. run-tests.py -l --keep-tmpdir test-serve.t
  3. Check the generated .hgrc, make sure it sets web.ipv6=1.
  4. Check the log file to make sure IPv6HTTPServer.__init__ is called.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -536,5 +536,6 @@ class Test(unittest.TestCase):
                  startport=defaults['port'], extraconfigopts=None,
                  py3kwarnings=False, shell=None, hgcommand=None,
-                 slowtimeout=defaults['slowtimeout'], usechg=False):
+                 slowtimeout=defaults['slowtimeout'], usechg=False,
+                 useipv6=False):
         """Create a test from parameters.
 
@@ -594,4 +595,9 @@ class Test(unittest.TestCase):
         self._chgsockdir = None
 
+        # If IPv6 is used, set web.ipv6=1 in hgrc so servers will use IPv6
+        if useipv6:
+            self._extraconfigopts = list(self._extraconfigopts)
+            self._extraconfigopts.append('web.ipv6 = True')
+
         # If we're not in --debug mode and reference output file exists,
         # check test output against it.
@@ -2318,5 +2324,6 @@ class TestRunner(object):
                     shell=self.options.shell,
                     hgcommand=self._hgcommand,
-                    usechg=bool(self.options.with_chg or self.options.chg))
+                    usechg=bool(self.options.with_chg or self.options.chg),
+                    useipv6=useipv6)
         t.should_reload = True
         return t
diff --git a/tests/test-basic.t b/tests/test-basic.t
--- a/tests/test-basic.t
+++ b/tests/test-basic.t
@@ -12,4 +12,5 @@ Create a repository:
   ui.mergemarkers=detailed
   ui.promptecho=True
+  web.ipv6=True (?)
   $ hg init t
   $ cd t
diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -200,4 +200,5 @@ check that local configs for the cached 
   ui.foo=bar
   ui.nontty=true
+  web.ipv6=True (?)
   *** runcommand init foo
   *** runcommand -R foo showconfig ui defaults
diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -59,10 +59,10 @@ Test case sensitive configuration
    {
     "name": "Section.KeY",
-    "source": "*.hgrc:16", (glob)
+    "source": "*.hgrc:*", (glob)
     "value": "Case Sensitive"
    },
    {
     "name": "Section.key",
-    "source": "*.hgrc:17", (glob)
+    "source": "*.hgrc:*", (glob)
     "value": "lower case"
    }
@@ -72,5 +72,5 @@ Test case sensitive configuration
    {
     "name": "Section.KeY",
-    "source": "*.hgrc:16", (glob)
+    "source": "*.hgrc:*", (glob)
     "value": "Case Sensitive"
    }


More information about the Mercurial-devel mailing list