Mercurial > public > mercurial-scm > hg
comparison mercurial/testing/revlog.py @ 52783:07740bd86fd9
rust-pyo3: reviving test-rust-revlog.py
This test file was removed in 7346f93be7a4. Adaptation to the
new `InnerRevlog` / `RustIndexProxy` structure was as easy as
redefining the `parserustindex()` method to use `RustIndexProxy`.
As we did before with `test-rust-ancestors.py`, we are preparing
a mixin class that will contain tests for both bindings.
Existing tests will migrate from `RustInnerRevlogTest`
(the one for `hg-cpython`) to the mixin.
author | Georges Racinet <georges.racinet@cloudcrane.io> |
---|---|
date | Sun, 22 Dec 2024 20:26:57 +0100 |
parents | cf5b47b885b1 |
children |
comparison
equal
deleted
inserted
replaced
52782:827889802d11 | 52783:07740bd86fd9 |
---|---|
42 rust_revlog.__name__ # force actual import | 42 rust_revlog.__name__ # force actual import |
43 except ImportError: | 43 except ImportError: |
44 rust_revlog = None | 44 rust_revlog = None |
45 | 45 |
46 | 46 |
47 try: | |
48 from ..pyo3_rustext import ( # pytype: disable=import-error | |
49 revlog as pyo3_revlog, | |
50 ) | |
51 | |
52 pyo3_revlog.__name__ # force actual import | |
53 except ImportError: | |
54 pyo3_revlog = None | |
55 | |
56 | |
47 @unittest.skipIf( | 57 @unittest.skipIf( |
48 cparsers is None, | 58 cparsers is None, |
49 'The C version of the "parsers" module is not available. It is needed for this test.', | 59 ( |
60 'The C version of the "parsers" module is not available. ' | |
61 'It is needed for this test.' | |
62 ), | |
50 ) | 63 ) |
51 class RevlogBasedTestBase(unittest.TestCase): | 64 class RevlogBasedTestBase(unittest.TestCase): |
52 def parseindex(self, data=None): | 65 def parseindex(self, data=None): |
53 if data is None: | 66 if data is None: |
54 data = data_non_inlined | 67 data = data_non_inlined |
63 # defaults | 76 # defaults |
64 revlog_data_config = revlog.DataConfig() | 77 revlog_data_config = revlog.DataConfig() |
65 revlog_delta_config = revlog.DeltaConfig() | 78 revlog_delta_config = revlog.DeltaConfig() |
66 revlog_feature_config = revlog.FeatureConfig() | 79 revlog_feature_config = revlog.FeatureConfig() |
67 | 80 |
81 @classmethod | |
82 def irl_class(cls): | |
83 return rust_revlog.InnerRevlog | |
84 | |
85 @classmethod | |
86 def nodetree(cls, idx): | |
87 return rust_revlog.NodeTree(idx) | |
88 | |
68 def make_inner_revlog( | 89 def make_inner_revlog( |
69 self, data=None, vfs_is_readonly=True, kind=KIND_CHANGELOG | 90 self, data=None, vfs_is_readonly=True, kind=KIND_CHANGELOG |
70 ): | 91 ): |
71 if data is None: | 92 if data is None: |
72 data = data_non_inlined | 93 data = data_non_inlined |
73 | 94 |
74 return rust_revlog.InnerRevlog( | 95 return self.irl_class()( |
75 vfs_base=b"Just a path", | 96 vfs_base=b"Just a path", |
76 fncache=None, # might be enough for now | 97 fncache=None, # might be enough for now |
77 vfs_is_readonly=vfs_is_readonly, | 98 vfs_is_readonly=vfs_is_readonly, |
78 index_data=data, | 99 index_data=data, |
79 index_file=b'test.i', | 100 index_file=b'test.i', |
89 use_persistent_nodemap=False, # until we cook one. | 110 use_persistent_nodemap=False, # until we cook one. |
90 ) | 111 ) |
91 | 112 |
92 def parserustindex(self, data=None): | 113 def parserustindex(self, data=None): |
93 return revlog.RustIndexProxy(self.make_inner_revlog(data=data)) | 114 return revlog.RustIndexProxy(self.make_inner_revlog(data=data)) |
115 | |
116 | |
117 @unittest.skipIf( | |
118 pyo3_revlog is None, | |
119 'The Rust PyO3 revlog module is not available. It is needed for this test.', | |
120 ) | |
121 class PyO3RevlogBasedTestBase(RustRevlogBasedTestBase): | |
122 @classmethod | |
123 def irl_class(cls): | |
124 return pyo3_revlog.InnerRevlog | |
125 | |
126 @classmethod | |
127 def nodetree(cls, idx): | |
128 return pyo3_revlog.NodeTree(idx) |