57
57
ue_scenarios = [('dirstate_Python',
58
58
{'update_entry': dirstate.py_update_entry})]
59
if has_dirstate_helpers_pyx:
60
pyrex_scenario = ('dirstate_Pyrex',
61
{'update_entry': _dirstate_helpers_pyx.update_entry})
62
ue_scenarios.append(pyrex_scenario)
59
if has_dirstate_helpers_c:
60
c_scenario = ('dirstate_C',
61
{'update_entry': _dirstate_helpers_c.update_entry})
62
ue_scenarios.append(c_scenario)
63
63
process_entry_tests, remaining_tests = tests.split_suite_by_condition(
64
64
remaining_tests, tests.condition_isinstance(TestUpdateEntry))
65
65
tests.multiply_tests(process_entry_tests,
70
70
pe_scenarios = [('dirstate_Python',
71
71
{'_process_entry': dirstate.ProcessEntryPython})]
72
if has_dirstate_helpers_pyx:
75
{'_process_entry': _dirstate_helpers_pyx.ProcessEntryC})
76
pe_scenarios.append(pyrex_scenario)
72
if has_dirstate_helpers_c:
73
c_scenario = ('dirstate_C',
74
{'_process_entry': _dirstate_helpers_c.ProcessEntryC})
75
pe_scenarios.append(c_scenario)
77
76
process_entry_tests, remaining_tests = tests.split_suite_by_condition(
78
77
remaining_tests, tests.condition_isinstance(TestProcessEntry))
79
78
tests.multiply_tests(process_entry_tests,
248
247
class TestBisectPathLeft(tests.TestCase, TestBisectPathMixin):
249
"""Run all Bisect Path tests against _bisect_path_left."""
248
"""Run all Bisect Path tests against _bisect_path_left_py."""
251
250
def get_bisect_path(self):
252
from bzrlib._dirstate_helpers_py import _bisect_path_left
253
return _bisect_path_left
251
from bzrlib._dirstate_helpers_py import _bisect_path_left_py
252
return _bisect_path_left_py
255
254
def get_bisect(self):
256
255
return bisect.bisect_left, 0
259
258
class TestCompiledBisectPathLeft(TestBisectPathLeft):
260
"""Run all Bisect Path tests against _bisect_path_lect"""
259
"""Run all Bisect Path tests against _bisect_path_right_c"""
262
261
_test_needs_features = [CompiledDirstateHelpersFeature]
264
263
def get_bisect_path(self):
265
from bzrlib._dirstate_helpers_pyx import _bisect_path_left
266
return _bisect_path_left
264
from bzrlib._dirstate_helpers_c import _bisect_path_left_c
265
return _bisect_path_left_c
269
268
class TestBisectPathRight(tests.TestCase, TestBisectPathMixin):
270
"""Run all Bisect Path tests against _bisect_path_right"""
269
"""Run all Bisect Path tests against _bisect_path_right_py"""
272
271
def get_bisect_path(self):
273
from bzrlib._dirstate_helpers_py import _bisect_path_right
274
return _bisect_path_right
272
from bzrlib._dirstate_helpers_py import _bisect_path_right_py
273
return _bisect_path_right_py
276
275
def get_bisect(self):
277
276
return bisect.bisect_right, -1
280
279
class TestCompiledBisectPathRight(TestBisectPathRight):
281
"""Run all Bisect Path tests against _bisect_path_right"""
280
"""Run all Bisect Path tests against _bisect_path_right_c"""
283
282
_test_needs_features = [CompiledDirstateHelpersFeature]
285
284
def get_bisect_path(self):
286
from bzrlib._dirstate_helpers_pyx import _bisect_path_right
287
return _bisect_path_right
285
from bzrlib._dirstate_helpers_c import _bisect_path_right_c
286
return _bisect_path_right_c
290
289
class TestBisectDirblock(tests.TestCase):
762
761
_test_needs_features = [CompiledDirstateHelpersFeature]
764
763
def get_read_dirblocks(self):
765
from bzrlib._dirstate_helpers_pyx import _read_dirblocks
766
return _read_dirblocks
764
from bzrlib._dirstate_helpers_c import _read_dirblocks_c
765
return _read_dirblocks_c
769
768
class TestUsingCompiledIfAvailable(tests.TestCase):
770
769
"""Check that any compiled functions that are available are the default.
772
771
It is possible to have typos, etc in the import line, such that
773
_dirstate_helpers_pyx is actually available, but the compiled functions are
772
_dirstate_helpers_c is actually available, but the compiled functions are
777
776
def test_bisect_dirblock(self):
778
777
if CompiledDirstateHelpersFeature.available():
779
from bzrlib._dirstate_helpers_pyx import bisect_dirblock
778
from bzrlib._dirstate_helpers_c import bisect_dirblock_c
779
self.assertIs(bisect_dirblock_c, dirstate.bisect_dirblock)
781
from bzrlib._dirstate_helpers_py import bisect_dirblock
782
self.assertIs(bisect_dirblock, dirstate.bisect_dirblock)
781
from bzrlib._dirstate_helpers_py import bisect_dirblock_py
782
self.assertIs(bisect_dirblock_py, dirstate.bisect_dirblock)
784
784
def test__bisect_path_left(self):
785
785
if CompiledDirstateHelpersFeature.available():
786
from bzrlib._dirstate_helpers_pyx import _bisect_path_left
786
from bzrlib._dirstate_helpers_c import _bisect_path_left_c
787
self.assertIs(_bisect_path_left_c, dirstate._bisect_path_left)
788
from bzrlib._dirstate_helpers_py import _bisect_path_left
789
self.assertIs(_bisect_path_left, dirstate._bisect_path_left)
789
from bzrlib._dirstate_helpers_py import _bisect_path_left_py
790
self.assertIs(_bisect_path_left_py, dirstate._bisect_path_left)
791
792
def test__bisect_path_right(self):
792
793
if CompiledDirstateHelpersFeature.available():
793
from bzrlib._dirstate_helpers_pyx import _bisect_path_right
794
from bzrlib._dirstate_helpers_c import _bisect_path_right_c
795
self.assertIs(_bisect_path_right_c, dirstate._bisect_path_right)
795
from bzrlib._dirstate_helpers_py import _bisect_path_right
796
self.assertIs(_bisect_path_right, dirstate._bisect_path_right)
797
from bzrlib._dirstate_helpers_py import _bisect_path_right_py
798
self.assertIs(_bisect_path_right_py, dirstate._bisect_path_right)
798
800
def test_cmp_by_dirs(self):
799
801
if CompiledDirstateHelpersFeature.available():
800
from bzrlib._dirstate_helpers_pyx import cmp_by_dirs
802
from bzrlib._dirstate_helpers_c import cmp_by_dirs_c
803
self.assertIs(cmp_by_dirs_c, dirstate.cmp_by_dirs)
802
from bzrlib._dirstate_helpers_py import cmp_by_dirs
803
self.assertIs(cmp_by_dirs, dirstate.cmp_by_dirs)
805
from bzrlib._dirstate_helpers_py import cmp_by_dirs_py
806
self.assertIs(cmp_by_dirs_py, dirstate.cmp_by_dirs)
805
808
def test__read_dirblocks(self):
806
809
if CompiledDirstateHelpersFeature.available():
807
from bzrlib._dirstate_helpers_pyx import _read_dirblocks
810
from bzrlib._dirstate_helpers_c import _read_dirblocks_c
811
self.assertIs(_read_dirblocks_c, dirstate._read_dirblocks)
809
from bzrlib._dirstate_helpers_py import _read_dirblocks
810
self.assertIs(_read_dirblocks, dirstate._read_dirblocks)
813
from bzrlib._dirstate_helpers_py import _read_dirblocks_py
814
self.assertIs(_read_dirblocks_py, dirstate._read_dirblocks)
812
816
def test_update_entry(self):
813
817
if CompiledDirstateHelpersFeature.available():
814
from bzrlib._dirstate_helpers_pyx import update_entry
818
from bzrlib._dirstate_helpers_c import update_entry
819
self.assertIs(update_entry, dirstate.update_entry)
816
from bzrlib.dirstate import update_entry
817
self.assertIs(update_entry, dirstate.update_entry)
821
from bzrlib.dirstate import py_update_entry
822
self.assertIs(py_update_entry, dirstate.py_update_entry)
819
824
def test_process_entry(self):
820
825
if CompiledDirstateHelpersFeature.available():
821
from bzrlib._dirstate_helpers_pyx import ProcessEntryC
826
from bzrlib._dirstate_helpers_c import ProcessEntryC
822
827
self.assertIs(ProcessEntryC, dirstate._process_entry)
824
829
from bzrlib.dirstate import ProcessEntryPython