[PATCH 2 of 5 V4] testing: expand Hypothesis tests with branch commands

David R. MacIver david at drmaciver.com
Wed Feb 24 14:22:56 UTC 2016


# HG changeset patch
# User David R. MacIver <david at drmaciver.com>
# Date 1456319203 0
#      Wed Feb 24 13:06:43 2016 +0000
# Node ID 3426830684771340e16691a213d52d92cf655854
# Parent  ce5a450c62aa6c8695f6a39d2965adf907f06903
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 ce5a450c62aa -r 342683068477 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):
@@ -236,6 +237,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()
@@ -346,6 +354,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,


More information about the Mercurial-devel mailing list