##// END OF EJS Templates
test: extract some generic data and utility from test-rust-ancestor.py...
marmoute -
r44397:8a8305f5 default
parent child Browse files
Show More
@@ -0,0 +1,38 b''
1 from __future__ import absolute_import
2 import unittest
3
4 # picked from test-parse-index2, copied rather than imported
5 # so that it stays stable even if test-parse-index2 changes or disappears.
6 data_non_inlined = (
7 b'\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01D\x19'
8 b'\x00\x07e\x12\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff'
9 b'\xff\xff\xff\xff\xd1\xf4\xbb\xb0\xbe\xfc\x13\xbd\x8c\xd3\x9d'
10 b'\x0f\xcd\xd9;\x8c\x07\x8cJ/\x00\x00\x00\x00\x00\x00\x00\x00\x00'
11 b'\x00\x00\x00\x00\x00\x00\x01D\x19\x00\x00\x00\x00\x00\xdf\x00'
12 b'\x00\x01q\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\xff'
13 b'\xff\xff\xff\xc1\x12\xb9\x04\x96\xa4Z1t\x91\xdfsJ\x90\xf0\x9bh'
14 b'\x07l&\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
15 b'\x00\x01D\xf8\x00\x00\x00\x00\x01\x1b\x00\x00\x01\xb8\x00\x00'
16 b'\x00\x01\x00\x00\x00\x02\x00\x00\x00\x01\xff\xff\xff\xff\x02\n'
17 b'\x0e\xc6&\xa1\x92\xae6\x0b\x02i\xfe-\xe5\xbao\x05\xd1\xe7\x00'
18 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01F'
19 b'\x13\x00\x00\x00\x00\x01\xec\x00\x00\x03\x06\x00\x00\x00\x01'
20 b'\x00\x00\x00\x03\x00\x00\x00\x02\xff\xff\xff\xff\x12\xcb\xeby1'
21 b'\xb6\r\x98B\xcb\x07\xbd`\x8f\x92\xd9\xc4\x84\xbdK\x00\x00\x00'
22 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00'
23 )
24
25
26 try:
27 from ..cext import parsers as cparsers
28 except ImportError:
29 cparsers = None
30
31
32 @unittest.skipIf(
33 cparsers is None,
34 'The C version of the "parsers" module is not available. It is needed for this test.',
35 )
36 class RevlogBasedTestBase(unittest.TestCase):
37 def parseindex(self):
38 return cparsers.parse_index2(data_non_inlined, False)[0]
@@ -7,6 +7,8 b' from mercurial import ('
7 node,
7 node,
8 )
8 )
9
9
10 from mercurial.testing import revlog as revlogtesting
11
10 try:
12 try:
11 from mercurial import rustext
13 from mercurial import rustext
12
14
@@ -27,34 +29,18 b' try:'
27 except ImportError:
29 except ImportError:
28 cparsers = None
30 cparsers = None
29
31
30 # picked from test-parse-index2, copied rather than imported
31 # so that it stays stable even if test-parse-index2 changes or disappears.
32 data_non_inlined = (
33 b'\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01D\x19'
34 b'\x00\x07e\x12\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff'
35 b'\xff\xff\xff\xff\xd1\xf4\xbb\xb0\xbe\xfc\x13\xbd\x8c\xd3\x9d'
36 b'\x0f\xcd\xd9;\x8c\x07\x8cJ/\x00\x00\x00\x00\x00\x00\x00\x00\x00'
37 b'\x00\x00\x00\x00\x00\x00\x01D\x19\x00\x00\x00\x00\x00\xdf\x00'
38 b'\x00\x01q\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\xff'
39 b'\xff\xff\xff\xc1\x12\xb9\x04\x96\xa4Z1t\x91\xdfsJ\x90\xf0\x9bh'
40 b'\x07l&\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
41 b'\x00\x01D\xf8\x00\x00\x00\x00\x01\x1b\x00\x00\x01\xb8\x00\x00'
42 b'\x00\x01\x00\x00\x00\x02\x00\x00\x00\x01\xff\xff\xff\xff\x02\n'
43 b'\x0e\xc6&\xa1\x92\xae6\x0b\x02i\xfe-\xe5\xbao\x05\xd1\xe7\x00'
44 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01F'
45 b'\x13\x00\x00\x00\x00\x01\xec\x00\x00\x03\x06\x00\x00\x00\x01'
46 b'\x00\x00\x00\x03\x00\x00\x00\x02\xff\xff\xff\xff\x12\xcb\xeby1'
47 b'\xb6\r\x98B\xcb\x07\xbd`\x8f\x92\xd9\xc4\x84\xbdK\x00\x00\x00'
48 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00'
49 )
50
51
32
52 @unittest.skipIf(
33 @unittest.skipIf(
53 rustext is None or cparsers is None,
34 rustext is None,
54 "rustext or the C Extension parsers module "
35 'The Rust version of the "ancestor" module is not available. It is needed'
55 "ancestor relies on is not available",
36 ' for this test.',
56 )
37 )
57 class rustancestorstest(unittest.TestCase):
38 @unittest.skipIf(
39 rustext is None,
40 'The Rust or C version of the "parsers" module, which the "ancestor" module'
41 ' relies on, is not available.',
42 )
43 class rustancestorstest(revlogtesting.RevlogBasedTestBase):
58 """Test the correctness of binding to Rust code.
44 """Test the correctness of binding to Rust code.
59
45
60 This test is merely for the binding to Rust itself: extraction of
46 This test is merely for the binding to Rust itself: extraction of
@@ -67,9 +53,6 b' class rustancestorstest(unittest.TestCas'
67 Algorithmic correctness is asserted by the Rust unit tests.
53 Algorithmic correctness is asserted by the Rust unit tests.
68 """
54 """
69
55
70 def parseindex(self):
71 return cparsers.parse_index2(data_non_inlined, False)[0]
72
73 def testiteratorrevlist(self):
56 def testiteratorrevlist(self):
74 idx = self.parseindex()
57 idx = self.parseindex()
75 # checking test assumption about the index binary data:
58 # checking test assumption about the index binary data:
@@ -150,7 +133,9 b' class rustancestorstest(unittest.TestCas'
150
133
151 def testgrapherror(self):
134 def testgrapherror(self):
152 data = (
135 data = (
153 data_non_inlined[: 64 + 27] + b'\xf2' + data_non_inlined[64 + 28 :]
136 revlogtesting.data_non_inlined[: 64 + 27]
137 + b'\xf2'
138 + revlogtesting.data_non_inlined[64 + 28 :]
154 )
139 )
155 idx = cparsers.parse_index2(data, False)[0]
140 idx = cparsers.parse_index2(data, False)[0]
156 with self.assertRaises(rustext.GraphError) as arc:
141 with self.assertRaises(rustext.GraphError) as arc:
General Comments 0
You need to be logged in to leave comments. Login now