[PATCH] testing: allow Hypothesis tests to disable extensions

Martin von Zweigbergk martinvonz at google.com
Mon Feb 29 00:56:55 EST 2016


Pushed to the clowncopter, thanks.

On Fri, Feb 26, 2016 at 9:16 AM, David R. MacIver <david at drmaciver.com> wrote:
> diff -r 18680fed3058 -r 9a28035d39f0 tests/test-verify-repo-operations.py
> --- a/tests/test-verify-repo-operations.py      Wed Feb 24 13:20:06 2016 +0000
> +++ b/tests/test-verify-repo-operations.py      Fri Feb 26 17:15:49 2016 +0000
> @@ -190,29 +192,32 @@
>          e = None
>          if not self.failed:
>              try:
> -                for ext in (
> -                    self.all_extensions - self.non_skippable_extensions
> -                ):
> -                    try:
> -                        os.environ["SKIP_EXTENSION"] = ext
> -                        output = subprocess.check_output([
> -                            runtests, path, "--local",
> -                        ], stderr=subprocess.STDOUT)
> -                        assert "Ran 1 test" in output, output
> -                    finally:
> -                        del os.environ["SKIP_EXTENSION"]
>                  output = subprocess.check_output([
>                      runtests, path, "--local", "--pure"
>                  ], stderr=subprocess.STDOUT)
>                  assert "Ran 1 test" in output, output
> +                for ext in (
> +                    self.all_extensions - self.non_skippable_extensions
> +                ):
> +                    tf = os.path.join(testtmp, "test-generated-no-%s.t" % (
> +                        ext,
> +                    ))
> +                    with open(tf, 'w') as o:
> +                        for l in ttest.splitlines():
> +                            if l.startswith("  $ hg"):
> +                                l = l.replace(
> +                                    "--config %s=" % (
> +                                        extensionconfigkey(ext),), "")
> +                            o.write(l + os.linesep)
> +                    with open(tf, 'r') as r:
> +                        t = r.read()
> +                        assert ext not in t, t
> +                    output = subprocess.check_output([
> +                        runtests, tf, "--local",
> +                    ], stderr=subprocess.STDOUT)
> +                    assert "Ran 1 test" in output, output
>              except subprocess.CalledProcessError as e:

I guess I didn't think of asking on an earlier patch, but why is this
rerunning needed? I read something about Hypothesis trying to minimize
found examples. I would have thought that that would ideally produce a
test case without the call to addextension("unrelatedextension").


More information about the Mercurial-devel mailing list