38
38
has_dirstate_helpers_pyx = False
41
class _CompiledDirstateHelpersFeature(tests.Feature):
43
return has_dirstate_helpers_pyx
45
def feature_name(self):
46
return 'bzrlib._dirstate_helpers_pyx'
47
CompiledDirstateHelpersFeature = _CompiledDirstateHelpersFeature()
41
compiled_dirstate_helpers_feature = tests.ModuleAvailableFeature(
42
'bzrlib._dirstate_helpers_pyx')
50
45
def load_tests(basic_tests, module, loader):
57
52
ue_scenarios = [('dirstate_Python',
58
53
{'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})
54
if compiled_dirstate_helpers_feature.available():
55
update_entry = compiled_dirstate_helpers_feature.module.update_entry
56
pyrex_scenario = ('dirstate_Pyrex', {'update_entry': update_entry})
62
57
ue_scenarios.append(pyrex_scenario)
63
58
process_entry_tests, remaining_tests = tests.split_suite_by_condition(
64
59
remaining_tests, tests.condition_isinstance(TestUpdateEntry))
70
65
pe_scenarios = [('dirstate_Python',
71
66
{'_process_entry': dirstate.ProcessEntryPython})]
72
if has_dirstate_helpers_pyx:
75
{'_process_entry': _dirstate_helpers_pyx.ProcessEntryC})
67
if compiled_dirstate_helpers_feature.available():
68
process_entry = compiled_dirstate_helpers_feature.module.ProcessEntryC
69
pyrex_scenario = ('dirstate_Pyrex', {'_process_entry': process_entry})
76
70
pe_scenarios.append(pyrex_scenario)
77
71
process_entry_tests, remaining_tests = tests.split_suite_by_condition(
78
72
remaining_tests, tests.condition_isinstance(TestProcessEntry))
259
253
class TestCompiledBisectPathLeft(TestBisectPathLeft):
260
254
"""Run all Bisect Path tests against _bisect_path_lect"""
262
_test_needs_features = [CompiledDirstateHelpersFeature]
256
_test_needs_features = [compiled_dirstate_helpers_feature]
264
258
def get_bisect_path(self):
265
259
from bzrlib._dirstate_helpers_pyx import _bisect_path_left
280
274
class TestCompiledBisectPathRight(TestBisectPathRight):
281
275
"""Run all Bisect Path tests against _bisect_path_right"""
283
_test_needs_features = [CompiledDirstateHelpersFeature]
277
_test_needs_features = [compiled_dirstate_helpers_feature]
285
279
def get_bisect_path(self):
286
280
from bzrlib._dirstate_helpers_pyx import _bisect_path_right
514
508
class TestCompiledCmpByDirs(TestCmpByDirs):
515
509
"""Test the pyrex implementation of cmp_by_dirs"""
517
_test_needs_features = [CompiledDirstateHelpersFeature]
511
_test_needs_features = [compiled_dirstate_helpers_feature]
519
513
def get_cmp_by_dirs(self):
520
514
from bzrlib._dirstate_helpers_pyx import cmp_by_dirs
665
659
class TestCompiledCmpPathByDirblock(TestCmpPathByDirblock):
666
660
"""Test the pyrex implementation of _cmp_path_by_dirblock"""
668
_test_needs_features = [CompiledDirstateHelpersFeature]
662
_test_needs_features = [compiled_dirstate_helpers_feature]
670
664
def get_cmp_by_dirs(self):
671
665
from bzrlib._dirstate_helpers_pyx import _cmp_path_by_dirblock
675
669
class TestMemRChr(tests.TestCase):
676
670
"""Test memrchr functionality"""
678
_test_needs_features = [CompiledDirstateHelpersFeature]
672
_test_needs_features = [compiled_dirstate_helpers_feature]
680
674
def assertMemRChr(self, expected, s, c):
681
675
from bzrlib._dirstate_helpers_pyx import _py_memrchr
763
757
class TestCompiledReadDirblocks(TestReadDirblocks):
764
758
"""Test the pyrex implementation of _read_dirblocks"""
766
_test_needs_features = [CompiledDirstateHelpersFeature]
760
_test_needs_features = [compiled_dirstate_helpers_feature]
768
762
def get_read_dirblocks(self):
769
763
from bzrlib._dirstate_helpers_pyx import _read_dirblocks
781
775
def test_bisect_dirblock(self):
782
if CompiledDirstateHelpersFeature.available():
776
if compiled_dirstate_helpers_feature.available():
783
777
from bzrlib._dirstate_helpers_pyx import bisect_dirblock
785
779
from bzrlib._dirstate_helpers_py import bisect_dirblock
786
780
self.assertIs(bisect_dirblock, dirstate.bisect_dirblock)
788
782
def test__bisect_path_left(self):
789
if CompiledDirstateHelpersFeature.available():
783
if compiled_dirstate_helpers_feature.available():
790
784
from bzrlib._dirstate_helpers_pyx import _bisect_path_left
792
786
from bzrlib._dirstate_helpers_py import _bisect_path_left
793
787
self.assertIs(_bisect_path_left, dirstate._bisect_path_left)
795
789
def test__bisect_path_right(self):
796
if CompiledDirstateHelpersFeature.available():
790
if compiled_dirstate_helpers_feature.available():
797
791
from bzrlib._dirstate_helpers_pyx import _bisect_path_right
799
793
from bzrlib._dirstate_helpers_py import _bisect_path_right
800
794
self.assertIs(_bisect_path_right, dirstate._bisect_path_right)
802
796
def test_cmp_by_dirs(self):
803
if CompiledDirstateHelpersFeature.available():
797
if compiled_dirstate_helpers_feature.available():
804
798
from bzrlib._dirstate_helpers_pyx import cmp_by_dirs
806
800
from bzrlib._dirstate_helpers_py import cmp_by_dirs
807
801
self.assertIs(cmp_by_dirs, dirstate.cmp_by_dirs)
809
803
def test__read_dirblocks(self):
810
if CompiledDirstateHelpersFeature.available():
804
if compiled_dirstate_helpers_feature.available():
811
805
from bzrlib._dirstate_helpers_pyx import _read_dirblocks
813
807
from bzrlib._dirstate_helpers_py import _read_dirblocks
814
808
self.assertIs(_read_dirblocks, dirstate._read_dirblocks)
816
810
def test_update_entry(self):
817
if CompiledDirstateHelpersFeature.available():
811
if compiled_dirstate_helpers_feature.available():
818
812
from bzrlib._dirstate_helpers_pyx import update_entry
820
814
from bzrlib.dirstate import update_entry
821
815
self.assertIs(update_entry, dirstate.update_entry)
823
817
def test_process_entry(self):
824
if CompiledDirstateHelpersFeature.available():
818
if compiled_dirstate_helpers_feature.available():
825
819
from bzrlib._dirstate_helpers_pyx import ProcessEntryC
826
820
self.assertIs(ProcessEntryC, dirstate._process_entry)