Bug 1054112 - Convert try-mandatory hook tests into .t tests; r=edmorley
authorGregory Szorc <gps@mozilla.com>
Thu, 14 Aug 2014 18:47:51 -0700
changeset 917 42b4b8f97dfa
parent 916 728e98cd7f5f
child 918 7f4e9b9b2783
push id129
push usergszorc@mozilla.com
push dateFri, 15 Aug 2014 17:47:15 +0000
treeherderversion-control-tools@6f1da8433d97 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedmorley
bugs1054112
Bug 1054112 - Convert try-mandatory hook tests into .t tests; r=edmorley The existing Python tests were converted to a .t test. Minor, hopefully irrelevant content of the test such as exact strings have changed. runtests.py before and after output: Ran 51 tests in 8.699s Ran 49 tests in 8.642s
hghooks/runtests.py
hghooks/tests/test-try-mandatory.t
--- a/hghooks/runtests.py
+++ b/hghooks/runtests.py
@@ -539,52 +539,16 @@ class TestTreeCommCentralClosureHook(Clo
     add(u, self.clonerepo, join(self.clonedir, "testfile"))
     commit(u, self.clonerepo, message="checkin 1")
     appendFile(join(self.clonedir, "testfile"), "checkin 1")
     commit(u, self.clonerepo, message="checkin 2 a=someone")
 
     push(u, self.clonerepo, dest=self.repodir)
     self.assertEqual(self.director.opened, 1)
 
-class TestTryMandatoryHook(ClosureHookTestHelpers, unittest.TestCase):
-  def setUp(self):
-    self.ui = ui.ui()
-    self.ui.quiet = True
-    self.ui.verbose = False
-    self.repodir = mkdtemp(prefix="hg-test")
-    init(self.ui, dest=self.repodir)
-    addHook(self.repodir, "try_mandatory.hook")
-    self.repo = hg.repository(self.ui, self.repodir)
-    self.clonedir = mkdtemp(prefix="hg-test")
-    clone(self.ui, self.repo, self.clonedir)
-    self.clonerepo = hg.repository(self.ui, self.clonedir)
-    ClosureHookTestHelpers.setUp(self)
-
-  def tearDown(self):
-    shutil.rmtree(self.repodir)
-    shutil.rmtree(self.clonedir)
-    ClosureHookTestHelpers.tearDown(self)
-
-  def testWithoutTrySyntax(self):
-    """Push one changeset, without using the try syntax should error."""
-    u = self.ui
-    appendFile(join(self.clonedir, "testfile"), "checkin 1")
-    add(u, self.clonerepo, join(self.clonedir, "testfile"))
-    commit(u, self.clonerepo, message="checkin 1 bug 12345")
-    self.assertRaises(util.Abort, push, u, self.clonerepo, dest=self.repodir)
-
-  def testWithTrySyntax(self):
-    """Push one changeset, with using the try syntax should succeed."""
-    u = self.ui
-    appendFile(join(self.clonedir, "testfile"), "checkin 1")
-    add(u, self.clonerepo, join(self.clonedir, "testfile"))
-    commit(u, self.clonerepo, message="checkin 1 try: -b do -p all")
-    result = push(u, self.clonerepo, dest=self.repodir)
-    self.assertEqual(result, 0)
-
 class TestCommitMessageHook(unittest.TestCase):
   def setUp(self):
     self.ui = ui.ui()
     self.ui.quiet = True
     self.ui.verbose = False
     self.repodir = mkdtemp(prefix="hg-TestCommitMessageHook")
     init(self.ui, dest=self.repodir)
     addHook(self.repodir, "commit-message.hook")
new file mode 100644
--- /dev/null
+++ b/hghooks/tests/test-try-mandatory.t
@@ -0,0 +1,51 @@
+  $ hg init server
+  $ cat >> server/.hg/hgrc << EOF
+  > [hooks]
+  > pretxnchangegroup.try_mandatory = python:mozhghooks.try_mandatory.hook
+  > EOF
+
+  $ hg init client
+  $ cd client
+
+Pushing a changeset without using try syntax should error
+
+  $ touch foo
+  $ hg commit -A -m 'Bug 123 - Add foo'
+  adding foo
+  $ hg push ../server
+  pushing to ../server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  
+  
+  ************************** ERROR ****************************
+  To push to try you must use try syntax in the push comment of the * (glob)
+  See http://trychooser.pub.build.mozilla.org/ to build your syntax
+  For assistance using the syntax, see https://wiki.mozilla.org/Build:TryChooser.
+  Thank you for helping to reduce CPU cyles by asking for exactly what you need.
+  *************************************************************
+  
+  
+  transaction abort!
+  rollback completed
+  abort: pretxnchangegroup.try_mandatory hook failed
+  [255]
+
+Pushing a changeset with try syntax on the tip should be allowed
+
+  $ echo 'working' > foo
+  $ hg commit -m 'try: -b do -p all'
+  $ hg push ../server
+  pushing to ../server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
+  Looks like you used try syntax, going ahead with the push.
+  If you don't get what you expected, check http://trychooser.pub.build.mozilla.org/
+  for help with building your trychooser request.
+  Thanks for helping save resources, you're the best!