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

login
register
mail settings
Submitter David MacIver
Date Feb. 26, 2016, 11:38 a.m.
Message ID <5d7131c267733e7b4201.1456486717@laser-shark>
Download mbox | patch
Permalink /patch/13406/
State Accepted
Headers show

Comments

David MacIver - Feb. 26, 2016, 11:38 a.m.
# HG changeset patch
# User David R. MacIver <david@drmaciver.com>
# Date 1456319203 0
#      Wed Feb 24 13:06:43 2016 +0000
# Node ID 5d7131c267733e7b4201c79b1dc2211b07d4398f
# Parent  d4d4992a94d51b52ee0c33de8bd4578c08364b64
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.

Patch

diff -r d4d4992a94d5 -r 5d7131c26773 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
@@ -133,6 +133,7 @@ 
     # be provided as arguments to future operations.
     paths = Bundle('paths')
     contents = Bundle('contents')
+    branches = Bundle('branches')
     committimes = Bundle('committimes')
 
     def __init__(self):
@@ -250,6 +251,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()
@@ -369,6 +377,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',
+            'cannot be used in a name',
+            'a branch of the same name already exists',
+            'is reserved',
+        ):
+            self.hg("branch", "--", branch)
+
+    @rule(branch=branches, clean=st.booleans())
+    def update(self, branch, clean):
+        with acceptableerrors(
+            'unknown revision',
+            'parse error',
+        ):
+            if clean:
+                self.hg("update", "-C", "--", branch)
+            else:
+                self.hg("update", "--", branch)
+
 settings.register_profile(
     'default',  settings(
         timeout=300,