diff tests/run-tests.py @ 31006:d4916aebf3d0

runtests: export LOCALIP Previously, tests hard-code local IP address as "127.0.0.1". That won't work for IPv6. This patch exports the $LOCALIP environment variable, which is set to "::1" if we decide to use IPv6.
author Jun Wu <quark@fb.com>
date Thu, 16 Feb 2017 08:01:19 -0800
parents 225f574e0645
children 636cf3f7620d
line wrap: on
line diff
--- a/tests/run-tests.py	Wed Feb 15 22:53:45 2017 -0800
+++ b/tests/run-tests.py	Thu Feb 16 08:01:19 2017 -0800
@@ -857,6 +857,12 @@
         else:
             return re.escape(p)
 
+    def _localip(self):
+        if self._useipv6:
+            return b'::1'
+        else:
+            return b'127.0.0.1'
+
     def _getenv(self):
         """Obtain environment variables to use during test execution."""
         def defineport(i):
@@ -881,6 +887,10 @@
         env["HGENCODINGMODE"] = "strict"
         env['HGIPV6'] = str(int(self._useipv6))
 
+        # LOCALIP could be ::1 or 127.0.0.1. Useful for tests that require raw
+        # IP addresses.
+        env['LOCALIP'] = self._localip()
+
         # Reset some environment variables to well-known values so that
         # the tests produce repeatable output.
         env['LANG'] = env['LC_ALL'] = env['LANGUAGE'] = 'C'