[PATCH 05 of 10 ipv6 V2] runtests: export LOCALIP

Martin von Zweigbergk martinvonz at google.com
Fri Feb 17 17:01:12 EST 2017


On Fri, Feb 17, 2017 at 10:51 AM, Jun Wu <quark at fb.com> wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1487260879 28800
> #      Thu Feb 16 08:01:19 2017 -0800
> # Node ID 9222c925de31506ee513f58a913ddec0c3a8a9c5
> # Parent  c34ad0f0fc375de9e2d96d17ddcb644d9054d154
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 9222c925de31
> 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.
>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -843,4 +843,5 @@ class Test(unittest.TestCase):
>              (br'(?m)^(saved backup bundle to .*\.hg)( \(glob\))?$',
>               br'\1 (glob)'),
> +            (br'([^0-9])%s' % re.escape(self._localip()), br'\1$LOCALIP'),

Tests use the hardcoded values still, so replacing the hardecode
values by $LOCALIP in the interpret output makes it fail (IIUC). I'm
moving this hunk to patch 7 and running tests on that now.

>              ]
>          r.append((self._escapepath(self._testtmp), b'$TESTTMP'))
> @@ -858,4 +859,10 @@ class Test(unittest.TestCase):
>              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."""
> @@ -882,4 +889,8 @@ class Test(unittest.TestCase):
>          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.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list