runtests: set web.ipv6 if we use IPv6
authorJun Wu <quark@fb.com>
Wed, 15 Feb 2017 16:43:27 -0800
changeset 31006 f07ca071a058
parent 31005 1f803482844a
child 31007 1ee685defe80
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.
tests/run-tests.py
tests/test-basic.t
tests/test-commandserver.t
tests/test-config.t
--- a/tests/run-tests.py	Wed Feb 15 16:22:22 2017 -0800
+++ b/tests/run-tests.py	Wed Feb 15 16:43:27 2017 -0800
@@ -535,7 +535,8 @@
                  timeout=defaults['timeout'],
                  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.
 
         path is the full path to the file defining the test.
@@ -593,6 +594,11 @@
         self._testtmp = None
         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.
         if debug:
@@ -2317,7 +2323,8 @@
                     py3kwarnings=self.options.py3k_warnings,
                     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
 
--- a/tests/test-basic.t	Wed Feb 15 16:22:22 2017 -0800
+++ b/tests/test-basic.t	Wed Feb 15 16:43:27 2017 -0800
@@ -11,6 +11,7 @@
   ui.interactive=False
   ui.mergemarkers=detailed
   ui.promptecho=True
+  web.ipv6=True (?)
   $ hg init t
   $ cd t
 
--- a/tests/test-commandserver.t	Wed Feb 15 16:22:22 2017 -0800
+++ b/tests/test-commandserver.t	Wed Feb 15 16:43:27 2017 -0800
@@ -199,6 +199,7 @@
   ui.usehttp2=true (?)
   ui.foo=bar
   ui.nontty=true
+  web.ipv6=True (?)
   *** runcommand init foo
   *** runcommand -R foo showconfig ui defaults
   defaults.backout=-d "0 0"
--- a/tests/test-config.t	Wed Feb 15 16:22:22 2017 -0800
+++ b/tests/test-config.t	Wed Feb 15 16:43:27 2017 -0800
@@ -58,12 +58,12 @@
   [
    {
     "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"
    }
   ]
@@ -71,7 +71,7 @@
   [
    {
     "name": "Section.KeY",
-    "source": "*.hgrc:16", (glob)
+    "source": "*.hgrc:*", (glob)
     "value": "Case Sensitive"
    }
   ]