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