annotate tests/test-rust-ancestor.py @ 52436:cf5b47b885b1

testing: stop skipping all Python tests of Rust revlog This base class was not adapted for the introduction of `InnerRevlog`, which also stopped exposing an `Index` class from `rustext`. As a consequence, `test-rust-ancestor.py` was always skipped (and would have been slightly broken). We remove the skipping conditions from `rustancestorstest`, as they now contradict or repeat those of the base class. Also, `LazyAncestors` objects apparently hold only one reference to the inner revlog (they had previously two references on the Rust index). What matters most of course is the return to `start_count` in these tests, i.e., that there is no memory leak nor double frees. In the Python test, we conflate the presence of the `pyo3_rustext` package with that of `rustext`, as we do not plan to support building one and not the other (we hope to convert fully to PyO3 soon). The skipping is actually done by the base test class.
author Georges Racinet <georges.racinet@cloudcrane.io>
date Sat, 30 Nov 2024 19:12:02 +0100
parents 03fdd4d7b5bd
children 20fe0bf9a9a5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
41056
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
1 import sys
40981
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
2
46114
59fa3890d40a node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents: 43950
diff changeset
3 from mercurial.node import wdirrev
41310
ab0d762d89ef rust-cpython: raising error.WdirUnsupported
Georges Racinet <georges.racinet@octobus.net>
parents: 41246
diff changeset
4
43950
8a8305f557d0 test: extract some generic data and utility from test-rust-ancestor.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43076
diff changeset
5 from mercurial.testing import revlog as revlogtesting
8a8305f557d0 test: extract some generic data and utility from test-rust-ancestor.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43076
diff changeset
6
40981
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
7 try:
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
8 from mercurial import rustext
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
9
41056
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
10 rustext.__name__ # trigger immediate actual import
40981
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
11 except ImportError:
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
12 rustext = None
41056
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
13 else:
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
14 # this would fail already without appropriate ancestor.__package__
41117
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
15 from mercurial.rustext.ancestor import (
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
16 AncestorsIterator,
41188
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
17 LazyAncestors,
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
18 MissingAncestors,
41117
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
19 )
41705
0c7b353ce100 rust-cpython: binding for headrevs()
Georges Racinet <georges.racinet@octobus.net>
parents: 41310
diff changeset
20 from mercurial.rustext import dagop
40981
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
21
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
22 try:
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
23 from mercurial.cext import parsers as cparsers
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
24 except ImportError:
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
25 cparsers = None
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
26
41056
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
27
51265
03fdd4d7b5bd rust-python-testing: separated base test classes
Georges Racinet on incendie.racinet.fr <georges@racinet.fr>
parents: 51262
diff changeset
28 class rustancestorstest(revlogtesting.RustRevlogBasedTestBase):
40981
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
29 """Test the correctness of binding to Rust code.
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
30
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
31 This test is merely for the binding to Rust itself: extraction of
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
32 Python variable, giving back the results etc.
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
33
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
34 It is not meant to test the algorithmic correctness of the operations
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
35 on ancestors it provides. Hence the very simple embedded index data is
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
36 good enough.
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
37
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
38 Algorithmic correctness is asserted by the Rust unit tests.
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
39 """
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
40
41056
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
41 def testiteratorrevlist(self):
51260
7eea2e4109ae rust-index: using the `hg::index::Index` in ancestors iterator and lazy set
Georges Racinet <georges.racinet@octobus.net>
parents: 50990
diff changeset
42 idx = self.parserustindex()
41056
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
43 # checking test assumption about the index binary data:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
44 self.assertEqual(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
45 {i: (r[5], r[6]) for i, r in enumerate(idx)},
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
46 {0: (-1, -1), 1: (0, -1), 2: (1, -1), 3: (2, -1)},
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
47 )
41056
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
48 ait = AncestorsIterator(idx, [3], 0, True)
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
49 self.assertEqual([r for r in ait], [3, 2, 1, 0])
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
50
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
51 ait = AncestorsIterator(idx, [3], 0, False)
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
52 self.assertEqual([r for r in ait], [2, 1, 0])
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
53
41117
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
54 def testlazyancestors(self):
51260
7eea2e4109ae rust-index: using the `hg::index::Index` in ancestors iterator and lazy set
Georges Racinet <georges.racinet@octobus.net>
parents: 50990
diff changeset
55 idx = self.parserustindex()
52436
cf5b47b885b1 testing: stop skipping all Python tests of Rust revlog
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 51265
diff changeset
56 start_count = sys.getrefcount(idx.inner) # should be 2 (see Python doc)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
57 self.assertEqual(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
58 {i: (r[5], r[6]) for i, r in enumerate(idx)},
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
59 {0: (-1, -1), 1: (0, -1), 2: (1, -1), 3: (2, -1)},
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
60 )
41117
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
61 lazy = LazyAncestors(idx, [3], 0, True)
52436
cf5b47b885b1 testing: stop skipping all Python tests of Rust revlog
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 51265
diff changeset
62 # the LazyAncestors instance holds just one reference to the
cf5b47b885b1 testing: stop skipping all Python tests of Rust revlog
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 51265
diff changeset
63 # inner revlog.
cf5b47b885b1 testing: stop skipping all Python tests of Rust revlog
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 51265
diff changeset
64 self.assertEqual(sys.getrefcount(idx.inner), start_count + 1)
41117
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
65
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
66 self.assertTrue(2 in lazy)
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
67 self.assertTrue(bool(lazy))
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
68 self.assertEqual(list(lazy), [3, 2, 1, 0])
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
69 # a second time to validate that we spawn new iterators
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
70 self.assertEqual(list(lazy), [3, 2, 1, 0])
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
71
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
72 # now let's watch the refcounts closer
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
73 ait = iter(lazy)
52436
cf5b47b885b1 testing: stop skipping all Python tests of Rust revlog
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 51265
diff changeset
74 self.assertEqual(sys.getrefcount(idx.inner), start_count + 2)
41117
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
75 del ait
52436
cf5b47b885b1 testing: stop skipping all Python tests of Rust revlog
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 51265
diff changeset
76 self.assertEqual(sys.getrefcount(idx.inner), start_count + 1)
41117
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
77 del lazy
52436
cf5b47b885b1 testing: stop skipping all Python tests of Rust revlog
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 51265
diff changeset
78 self.assertEqual(sys.getrefcount(idx.inner), start_count)
41117
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
79
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
80 # let's check bool for an empty one
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
81 self.assertFalse(LazyAncestors(idx, [0], 0, False))
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
82
41188
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
83 def testmissingancestors(self):
51261
59d81768ad6d rust-index: using `hg::index::Index` in MissingAncestors
Georges Racinet on incendie.racinet.fr <georges@racinet.fr>
parents: 51260
diff changeset
84 idx = self.parserustindex()
41188
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
85 missanc = MissingAncestors(idx, [1])
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
86 self.assertTrue(missanc.hasbases())
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
87 self.assertEqual(missanc.missingancestors([3]), [2, 3])
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
88 missanc.addbases({2})
41243
5257e6299d4c rust-cpython: set conversion for MissingAncestors.bases()
Georges Racinet <georges.racinet@octobus.net>
parents: 41188
diff changeset
89 self.assertEqual(missanc.bases(), {1, 2})
41188
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
90 self.assertEqual(missanc.missingancestors([3]), [3])
41246
619ee4039bd4 rust: MissingAncestors.basesheads()
Georges Racinet <georges.racinet@octobus.net>
parents: 41243
diff changeset
91 self.assertEqual(missanc.basesheads(), {2})
41188
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
92
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
93 def testmissingancestorsremove(self):
51261
59d81768ad6d rust-index: using `hg::index::Index` in MissingAncestors
Georges Racinet on incendie.racinet.fr <georges@racinet.fr>
parents: 51260
diff changeset
94 idx = self.parserustindex()
41188
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
95 missanc = MissingAncestors(idx, [1])
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
96 revs = {0, 1, 2, 3}
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
97 missanc.removeancestorsfrom(revs)
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
98 self.assertEqual(revs, {2, 3})
006c9ce486fa rust-cpython: bindings for MissingAncestors
Georges Racinet <georges.racinet@octobus.net>
parents: 41117
diff changeset
99
41056
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
100 def testrefcount(self):
51260
7eea2e4109ae rust-index: using the `hg::index::Index` in ancestors iterator and lazy set
Georges Racinet <georges.racinet@octobus.net>
parents: 50990
diff changeset
101 idx = self.parserustindex()
52436
cf5b47b885b1 testing: stop skipping all Python tests of Rust revlog
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 51265
diff changeset
102 start_count = sys.getrefcount(idx.inner)
41056
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
103
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
104 # refcount increases upon iterator init...
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
105 ait = AncestorsIterator(idx, [3], 0, True)
52436
cf5b47b885b1 testing: stop skipping all Python tests of Rust revlog
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 51265
diff changeset
106 self.assertEqual(sys.getrefcount(idx.inner), start_count + 1)
41056
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
107 self.assertEqual(next(ait), 3)
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
108
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
109 # and decreases once the iterator is removed
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
110 del ait
52436
cf5b47b885b1 testing: stop skipping all Python tests of Rust revlog
Georges Racinet <georges.racinet@cloudcrane.io>
parents: 51265
diff changeset
111 self.assertEqual(sys.getrefcount(idx.inner), start_count)
41056
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
112
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
113 # and removing ref to the index after iterator init is no issue
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
114 ait = AncestorsIterator(idx, [3], 0, True)
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
115 del idx
41117
b31a41f24864 rust-cpython: binding for LazyAncestors
Georges Racinet <gracinet@anybox.fr>
parents: 41056
diff changeset
116 self.assertEqual(list(ait), [3, 2, 1, 0])
40981
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
117
51260
7eea2e4109ae rust-index: using the `hg::index::Index` in ancestors iterator and lazy set
Georges Racinet <georges.racinet@octobus.net>
parents: 50990
diff changeset
118 # the index is not tracked by the GC, hence there is nothing more
7eea2e4109ae rust-index: using the `hg::index::Index` in ancestors iterator and lazy set
Georges Racinet <georges.racinet@octobus.net>
parents: 50990
diff changeset
119 # we can assert to check that it is properly deleted once its refcount
7eea2e4109ae rust-index: using the `hg::index::Index` in ancestors iterator and lazy set
Georges Racinet <georges.racinet@octobus.net>
parents: 50990
diff changeset
120 # drops to 0
7eea2e4109ae rust-index: using the `hg::index::Index` in ancestors iterator and lazy set
Georges Racinet <georges.racinet@octobus.net>
parents: 50990
diff changeset
121
40981
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
122 def testgrapherror(self):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
123 data = (
43950
8a8305f557d0 test: extract some generic data and utility from test-rust-ancestor.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43076
diff changeset
124 revlogtesting.data_non_inlined[: 64 + 27]
8a8305f557d0 test: extract some generic data and utility from test-rust-ancestor.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43076
diff changeset
125 + b'\xf2'
8a8305f557d0 test: extract some generic data and utility from test-rust-ancestor.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43076
diff changeset
126 + revlogtesting.data_non_inlined[64 + 28 :]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
127 )
51260
7eea2e4109ae rust-index: using the `hg::index::Index` in ancestors iterator and lazy set
Georges Racinet <georges.racinet@octobus.net>
parents: 50990
diff changeset
128 idx = self.parserustindex(data=data)
41056
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
129 with self.assertRaises(rustext.GraphError) as arc:
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
130 AncestorsIterator(idx, [1], -1, False)
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
131 exc = arc.exception
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
132 self.assertIsInstance(exc, ValueError)
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
133 # rust-cpython issues appropriate str instances for Python 2 and 3
d9f439fcdb4c rust-cpython: binding for AncestorsIterator
Georges Racinet <gracinet@anybox.fr>
parents: 40981
diff changeset
134 self.assertEqual(exc.args, ('ParentOutOfRange', 1))
40981
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
135
41310
ab0d762d89ef rust-cpython: raising error.WdirUnsupported
Georges Racinet <georges.racinet@octobus.net>
parents: 41246
diff changeset
136 def testwdirunsupported(self):
ab0d762d89ef rust-cpython: raising error.WdirUnsupported
Georges Racinet <georges.racinet@octobus.net>
parents: 41246
diff changeset
137 # trying to access ancestors of the working directory raises
51260
7eea2e4109ae rust-index: using the `hg::index::Index` in ancestors iterator and lazy set
Georges Racinet <georges.racinet@octobus.net>
parents: 50990
diff changeset
138 idx = self.parserustindex()
50990
4c5f6e95df84 rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48966
diff changeset
139 with self.assertRaises(rustext.GraphError) as arc:
46114
59fa3890d40a node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents: 43950
diff changeset
140 list(AncestorsIterator(idx, [wdirrev], -1, False))
40981
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
141
50990
4c5f6e95df84 rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48966
diff changeset
142 exc = arc.exception
4c5f6e95df84 rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48966
diff changeset
143 self.assertIsInstance(exc, ValueError)
4c5f6e95df84 rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48966
diff changeset
144 # rust-cpython issues appropriate str instances for Python 2 and 3
4c5f6e95df84 rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48966
diff changeset
145 self.assertEqual(exc.args, ('InvalidRevision', wdirrev))
4c5f6e95df84 rust: make `Revision` a newtype
Rapha?l Gom?s <rgomes@octobus.net>
parents: 48966
diff changeset
146
41705
0c7b353ce100 rust-cpython: binding for headrevs()
Georges Racinet <georges.racinet@octobus.net>
parents: 41310
diff changeset
147 def testheadrevs(self):
51262
578c049f0408 rust-index: using `hg::index::Index` in `hg-cpython::dagops`
Georges Racinet <georges.racinet@octobus.net>
parents: 51261
diff changeset
148 idx = self.parserustindex()
41705
0c7b353ce100 rust-cpython: binding for headrevs()
Georges Racinet <georges.racinet@octobus.net>
parents: 41310
diff changeset
149 self.assertEqual(dagop.headrevs(idx, [1, 2, 3]), {3})
0c7b353ce100 rust-cpython: binding for headrevs()
Georges Racinet <georges.racinet@octobus.net>
parents: 41310
diff changeset
150
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
151
40981
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
152 if __name__ == '__main__':
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
153 import silenttestrunner
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41705
diff changeset
154
40981
74f41329bf55 rust-cpython: testing the bindings from Python
Georges Racinet <gracinet@anybox.fr>
parents:
diff changeset
155 silenttestrunner.main(__name__)