Patchwork [hglib] test: fix a test regression after log behavior fix in mercurial

login
register
mail settings
Submitter Alexander Plavin
Date April 25, 2013, 9:47 p.m.
Message ID <9c05d1ae50c047a9cfcf.1366926444@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1482/
State Changes Requested
Headers show

Comments

Alexander Plavin - April 25, 2013, 9:47 p.m.
# HG changeset patch
# User Alexander Plavin <me@aplavin.ru>
# Date 1366926368 -14400
#      Fri Apr 26 01:46:08 2013 +0400
# Node ID 9c05d1ae50c047a9cfcf9246873a97ebad1a50a8
# Parent  9324a89dd84e1562b87556a3b2788fdf04ba8179
test: fix a test regression after log behavior fix in mercurial

hg log behavior on empty repositories changed, so modify test cases accordingly

\ No newline at end of file
Matt Mackall - April 25, 2013, 9:59 p.m.
On Fri, 2013-04-26 at 01:47 +0400, Alexander Plavin wrote:
> # HG changeset patch
> # User Alexander Plavin <me@aplavin.ru>
> # Date 1366926368 -14400
> #      Fri Apr 26 01:46:08 2013 +0400
> # Node ID 9c05d1ae50c047a9cfcf9246873a97ebad1a50a8
> # Parent  9324a89dd84e1562b87556a3b2788fdf04ba8179
> test: fix a test regression after log behavior fix in mercurial
> 
> hg log behavior on empty repositories changed, so modify test cases accordingly

If you look carefully at the Buildbot, you'll see that we're running
hglib against multiple versions of hg. They're intentionally not closely
coupled.

So the test here has to instead be more liberal somehow and accept both
types of errors or the code that's calling 'log' has to only generate
one. This latter may be slightly preferable.

> diff -r 9324a89dd84e -r 9c05d1ae50c0 tests/test-context.py
> --- a/tests/test-context.py	Tue Apr 23 22:11:26 2013 +0200
> +++ b/tests/test-context.py	Fri Apr 26 01:46:08 2013 +0400
> @@ -1,9 +1,10 @@
> +from hglib.error import CommandError
>  import common, hglib
>  from hglib import context
>  
>  class test_context(common.basetest):
>      def test_non_existent(self):
> -        self.assertRaises(ValueError, context.changectx, self.client, 'foo')
> +        self.assertRaises(CommandError, context.changectx, self.client, 'foo')
>  
>      def test_basic(self):
>          self.append('a', 'a')
> diff -r 9324a89dd84e -r 9c05d1ae50c0 tests/test-log.py
> --- a/tests/test-log.py	Tue Apr 23 22:11:26 2013 +0200
> +++ b/tests/test-log.py	Fri Apr 26 01:46:08 2013 +0400
> @@ -1,5 +1,6 @@
> +from hglib.error import CommandError
>  import common
> -import hglib
> +
>  
>  class test_log(common.basetest):
>      def test_basic(self):
> @@ -16,3 +17,9 @@
>  
>          self.assertEquals(revs[0], self.client.log('0')[0])
>          self.assertEquals(self.client.log(), self.client.log(files=['a']))
> +
> +    def test_errors(self):
> +        self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
> +        self.append('a', 'a')
> +        self.client.commit('first', addremove=True)
> +        self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')
> \ No newline at end of file
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r 9324a89dd84e -r 9c05d1ae50c0 tests/test-context.py
--- a/tests/test-context.py	Tue Apr 23 22:11:26 2013 +0200
+++ b/tests/test-context.py	Fri Apr 26 01:46:08 2013 +0400
@@ -1,9 +1,10 @@ 
+from hglib.error import CommandError
 import common, hglib
 from hglib import context
 
 class test_context(common.basetest):
     def test_non_existent(self):
-        self.assertRaises(ValueError, context.changectx, self.client, 'foo')
+        self.assertRaises(CommandError, context.changectx, self.client, 'foo')
 
     def test_basic(self):
         self.append('a', 'a')
diff -r 9324a89dd84e -r 9c05d1ae50c0 tests/test-log.py
--- a/tests/test-log.py	Tue Apr 23 22:11:26 2013 +0200
+++ b/tests/test-log.py	Fri Apr 26 01:46:08 2013 +0400
@@ -1,5 +1,6 @@ 
+from hglib.error import CommandError
 import common
-import hglib
+
 
 class test_log(common.basetest):
     def test_basic(self):
@@ -16,3 +17,9 @@ 
 
         self.assertEquals(revs[0], self.client.log('0')[0])
         self.assertEquals(self.client.log(), self.client.log(files=['a']))
+
+    def test_errors(self):
+        self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
+        self.append('a', 'a')
+        self.client.commit('first', addremove=True)
+        self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')