comparison mercurial/testing/revlog.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 f4733654f144
children 07740bd86fd9
comparison
equal deleted inserted replaced
52435:544b9d3075f4 52436:cf5b47b885b1
21 b'\x00\x00\x00\x03\x00\x00\x00\x02\xff\xff\xff\xff\x12\xcb\xeby1' 21 b'\x00\x00\x00\x03\x00\x00\x00\x02\xff\xff\xff\xff\x12\xcb\xeby1'
22 b'\xb6\r\x98B\xcb\x07\xbd`\x8f\x92\xd9\xc4\x84\xbdK\x00\x00\x00' 22 b'\xb6\r\x98B\xcb\x07\xbd`\x8f\x92\xd9\xc4\x84\xbdK\x00\x00\x00'
23 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00' 23 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00'
24 ) 24 )
25 25
26 from ..revlogutils.constants import REVLOGV1 26 from ..revlogutils.constants import (
27 KIND_CHANGELOG,
28 )
29 from .. import revlog
27 30
28 31
29 try: 32 try:
30 from ..cext import parsers as cparsers # pytype: disable=import-error 33 from ..cext import parsers as cparsers # pytype: disable=import-error
31 except ImportError: 34 except ImportError:
32 cparsers = None 35 cparsers = None
33 36
34 try: 37 try:
35 from ..rustext.revlog import ( # pytype: disable=import-error 38 from ..rustext import ( # pytype: disable=import-error
36 Index as RustIndex, 39 revlog as rust_revlog,
37 ) 40 )
41
42 rust_revlog.__name__ # force actual import
38 except ImportError: 43 except ImportError:
39 RustIndex = None 44 rust_revlog = None
40 45
41 46
42 @unittest.skipIf( 47 @unittest.skipIf(
43 cparsers is None, 48 cparsers is None,
44 'The C version of the "parsers" module is not available. It is needed for this test.', 49 'The C version of the "parsers" module is not available. It is needed for this test.',
49 data = data_non_inlined 54 data = data_non_inlined
50 return cparsers.parse_index2(data, False)[0] 55 return cparsers.parse_index2(data, False)[0]
51 56
52 57
53 @unittest.skipIf( 58 @unittest.skipIf(
54 RustIndex is None, 59 rust_revlog is None,
55 'The Rust index is not available. It is needed for this test.', 60 'The Rust revlog module is not available. It is needed for this test.',
56 ) 61 )
57 class RustRevlogBasedTestBase(unittest.TestCase): 62 class RustRevlogBasedTestBase(unittest.TestCase):
58 def parserustindex(self, data=None): 63 # defaults
64 revlog_data_config = revlog.DataConfig()
65 revlog_delta_config = revlog.DeltaConfig()
66 revlog_feature_config = revlog.FeatureConfig()
67
68 def make_inner_revlog(
69 self, data=None, vfs_is_readonly=True, kind=KIND_CHANGELOG
70 ):
59 if data is None: 71 if data is None:
60 data = data_non_inlined 72 data = data_non_inlined
61 # not inheriting RevlogBasedTestCase to avoid having a 73
62 # `parseindex` method that would be shadowed by future subclasses 74 return rust_revlog.InnerRevlog(
63 # this duplication will soon be removed 75 vfs_base=b"Just a path",
64 return RustIndex(data, REVLOGV1) 76 fncache=None, # might be enough for now
77 vfs_is_readonly=vfs_is_readonly,
78 index_data=data,
79 index_file=b'test.i',
80 data_file=b'test.d',
81 sidedata_file=None,
82 inline=False,
83 data_config=self.revlog_data_config,
84 delta_config=self.revlog_delta_config,
85 feature_config=self.revlog_feature_config,
86 chunk_cache=None,
87 default_compression_header=None,
88 revlog_type=kind,
89 use_persistent_nodemap=False, # until we cook one.
90 )
91
92 def parserustindex(self, data=None):
93 return revlog.RustIndexProxy(self.make_inner_revlog(data=data))