Patchwork [2,of,5,V5] testing: expand Hypothesis tests with branch commands

login
register
mail settings
Submitter David MacIver
Date Feb. 24, 2016, 6:42 p.m.
Message ID <b661c4938bbb3a6723ee.1456339368@laser-shark>
Download mbox | patch
Permalink /patch/13358/
State Superseded
Headers show

Comments

David MacIver - Feb. 24, 2016, 6:42 p.m.
# HG changeset patch
# User David R. MacIver <david@drmaciver.com>
# Date 1456319203 0
#      Wed Feb 24 13:06:43 2016 +0000
# Node ID b661c4938bbb3a6723eecd0ed35d0294438ad9b6
# Parent  cceba7c42b31fea5288123596b5e8483040c4e14
testing: expand Hypothesis tests with branch commands

This builds on the previous work to add Hypothesis based stateful
testing to add branching commands to the model.
Martin von Zweigbergk - Feb. 24, 2016, 9:21 p.m.
On Wed, Feb 24, 2016 at 10:42 AM, David R. MacIver <david@drmaciver.com> wrote:
> # HG changeset patch
> # User David R. MacIver <david@drmaciver.com>
> # Date 1456319203 0
> #      Wed Feb 24 13:06:43 2016 +0000
> # Node ID b661c4938bbb3a6723eecd0ed35d0294438ad9b6
> # Parent  cceba7c42b31fea5288123596b5e8483040c4e14
> testing: expand Hypothesis tests with branch commands
>
> This builds on the previous work to add Hypothesis based stateful
> testing to add branching commands to the model.
>
> diff -r cceba7c42b31 -r b661c4938bbb tests/test-verify-repo-operations.py
> --- a/tests/test-verify-repo-operations.py      Wed Feb 24 13:05:45 2016 +0000
> +++ b/tests/test-verify-repo-operations.py      Wed Feb 24 13:06:43 2016 +0000
> @@ -114,6 +114,7 @@
>      # generated which may be provided as arguments to future rules.
>      paths = Bundle('paths')
>      contents = Bundle('contents')
> +    branches = Bundle('branches')
>      committimes = Bundle('committimes')
>
>      def __init__(self):
> @@ -233,6 +234,13 @@
>      def gencontent(self, content):
>          return content
>
> +    @rule(
> +        target=branches,
> +        name=safetext,
> +    )
> +    def genbranch(self, name):
> +        return name
> +
>      @rule(target=paths, source=paths)
>      def lowerpath(self, source):
>          return source.lower()
> @@ -348,6 +356,32 @@
>      def export(self):
>          self.hg("export")
>
> +    # Section: Branch management
> +    @rule()
> +    def checkbranch(self):
> +        self.hg("branch")
> +
> +    @rule(branch=branches)
> +    def switchbranch(self, branch):
> +        with acceptableerrors(
> +            'cannot use an integer as a name',
> +            'be used in a name',

nit: clearer if you include the initial "cannot".

> +            'a branch of the same name already exists',
> +            'is reserved',
> +        ):
> +            self.hg("branch", "--", branch)
> +
> +    @rule(branch=branches, c=st.booleans())
> +    def update(self, branch, c):

nit: I think "clean" is clearer than "c".

> +        with acceptableerrors(
> +            'unknown revision',
> +            'parse error',
> +        ):
> +            if c:
> +                self.hg("update", "-C", "--", branch)
> +            else:
> +                self.hg("update", "--", branch)
> +
>  settings.register_profile(
>      'default',  settings(
>          timeout=300,
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r cceba7c42b31 -r b661c4938bbb tests/test-verify-repo-operations.py
--- a/tests/test-verify-repo-operations.py	Wed Feb 24 13:05:45 2016 +0000
+++ b/tests/test-verify-repo-operations.py	Wed Feb 24 13:06:43 2016 +0000
@@ -114,6 +114,7 @@ 
     # generated which may be provided as arguments to future rules.
     paths = Bundle('paths')
     contents = Bundle('contents')
+    branches = Bundle('branches')
     committimes = Bundle('committimes')
 
     def __init__(self):
@@ -233,6 +234,13 @@ 
     def gencontent(self, content):
         return content
 
+    @rule(
+        target=branches,
+        name=safetext,
+    )
+    def genbranch(self, name):
+        return name
+
     @rule(target=paths, source=paths)
     def lowerpath(self, source):
         return source.lower()
@@ -348,6 +356,32 @@ 
     def export(self):
         self.hg("export")
 
+    # Section: Branch management
+    @rule()
+    def checkbranch(self):
+        self.hg("branch")
+
+    @rule(branch=branches)
+    def switchbranch(self, branch):
+        with acceptableerrors(
+            'cannot use an integer as a name',
+            'be used in a name',
+            'a branch of the same name already exists',
+            'is reserved',
+        ):
+            self.hg("branch", "--", branch)
+
+    @rule(branch=branches, c=st.booleans())
+    def update(self, branch, c):
+        with acceptableerrors(
+            'unknown revision',
+            'parse error',
+        ):
+            if c:
+                self.hg("update", "-C", "--", branch)
+            else:
+                self.hg("update", "--", branch)
+
 settings.register_profile(
     'default',  settings(
         timeout=300,