##// END OF EJS Templates
testing: allow Hypothesis to enable extensions...
David R. MacIver -
r28258:fc7ee50a default
parent child Browse files
Show More
@@ -37,7 +37,8 b' import silenttestrunner'
37 37 import subprocess
38 38
39 39 from hypothesis.errors import HypothesisException
40 from hypothesis.stateful import rule, RuleBasedStateMachine, Bundle
40 from hypothesis.stateful import (
41 rule, RuleBasedStateMachine, Bundle, precondition)
41 42 from hypothesis import settings, note, strategies as st
42 43 from hypothesis.configuration import set_hypothesis_home_dir
43 44
@@ -155,6 +156,9 b' class verifyingstatemachine(RuleBasedSta'
155 156 self.mkdirp("repo1")
156 157 self.cd("repo1")
157 158 self.hg("init")
159 self.extensions = {}
160 self.all_extensions = set()
161 self.non_skippable_extensions = set()
158 162
159 163 def teardown(self):
160 164 """On teardown we clean up after ourselves as usual, but we also
@@ -185,6 +189,17 b' class verifyingstatemachine(RuleBasedSta'
185 189 e = None
186 190 if not self.failed:
187 191 try:
192 for ext in (
193 self.all_extensions - self.non_skippable_extensions
194 ):
195 try:
196 os.environ["SKIP_EXTENSION"] = ext
197 output = subprocess.check_output([
198 runtests, path, "--local",
199 ], stderr=subprocess.STDOUT)
200 assert "Ran 1 test" in output, output
201 finally:
202 del os.environ["SKIP_EXTENSION"]
188 203 output = subprocess.check_output([
189 204 runtests, path, "--local", "--pure"
190 205 ], stderr=subprocess.STDOUT)
@@ -471,6 +486,50 b' class verifyingstatemachine(RuleBasedSta'
471 486 else:
472 487 self.hg("update", "--", branch)
473 488
489 # Section: Extension management
490 def hasextension(self, extension):
491 repo = self.currentrepo
492 return repo in self.extensions and extension in self.extensions[repo]
493
494 def commandused(self, extension):
495 assert extension in self.all_extensions
496 self.non_skippable_extensions.add(extension)
497
498 @rule(extension=st.sampled_from((
499 'shelve', 'mq', 'blackbox',
500 )))
501 def addextension(self, extension):
502 self.all_extensions.add(extension)
503 extensions = self.extensions.setdefault(self.currentrepo, set())
504 if extension in extensions:
505 return
506 extensions.add(extension)
507 if not os.path.exists(hgrc):
508 self.command("touch", hgrc)
509 with open(hgrc, 'a') as o:
510 line = "[extensions]\n%s=\n" % (extension,)
511 o.write(line)
512 for l in line.splitlines():
513 self.log.append((
514 '$ if test "$SKIP_EXTENSION" != "%s" ; '
515 'then echo %r >> %s; fi') % (
516 extension, l, hgrc,))
517
518 # Section: Commands from the shelve extension
519 @rule()
520 @precondition(lambda self: self.hasextension("shelve"))
521 def shelve(self):
522 self.commandused("shelve")
523 with acceptableerrors("nothing changed"):
524 self.hg("shelve")
525
526 @rule()
527 @precondition(lambda self: self.hasextension("shelve"))
528 def unshelve(self):
529 self.commandused("shelve")
530 with acceptableerrors("no shelved changes to apply"):
531 self.hg("unshelve")
532
474 533 settings.register_profile(
475 534 'default', settings(
476 535 timeout=300,
General Comments 0
You need to be logged in to leave comments. Login now