~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__dirstate_helpers.py

  • Committer: Robert Collins
  • Date: 2009-12-22 23:09:50 UTC
  • mfrom: (4918 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4920.
  • Revision ID: robertc@robertcollins.net-20091222230950-39gjmost0lmu9ufg
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    has_dirstate_helpers_pyx = False
39
39
 
40
40
 
41
 
class _CompiledDirstateHelpersFeature(tests.Feature):
42
 
    def _probe(self):
43
 
        return has_dirstate_helpers_pyx
44
 
 
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')
48
43
 
49
44
 
50
45
def load_tests(basic_tests, module, loader):
56
51
 
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))
69
64
 
70
65
    pe_scenarios = [('dirstate_Python',
71
66
                     {'_process_entry': dirstate.ProcessEntryPython})]
72
 
    if has_dirstate_helpers_pyx:
73
 
        pyrex_scenario = (
74
 
            'dirstate_Pyrex',
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"""
261
255
 
262
 
    _test_needs_features = [CompiledDirstateHelpersFeature]
 
256
    _test_needs_features = [compiled_dirstate_helpers_feature]
263
257
 
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"""
282
276
 
283
 
    _test_needs_features = [CompiledDirstateHelpersFeature]
 
277
    _test_needs_features = [compiled_dirstate_helpers_feature]
284
278
 
285
279
    def get_bisect_path(self):
286
280
        from bzrlib._dirstate_helpers_pyx import _bisect_path_right
392
386
    compiled version.
393
387
    """
394
388
 
395
 
    _test_needs_features = [CompiledDirstateHelpersFeature]
 
389
    _test_needs_features = [compiled_dirstate_helpers_feature]
396
390
 
397
391
    def get_bisect_dirblock(self):
398
392
        from bzrlib._dirstate_helpers_pyx import bisect_dirblock
514
508
class TestCompiledCmpByDirs(TestCmpByDirs):
515
509
    """Test the pyrex implementation of cmp_by_dirs"""
516
510
 
517
 
    _test_needs_features = [CompiledDirstateHelpersFeature]
 
511
    _test_needs_features = [compiled_dirstate_helpers_feature]
518
512
 
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"""
667
661
 
668
 
    _test_needs_features = [CompiledDirstateHelpersFeature]
 
662
    _test_needs_features = [compiled_dirstate_helpers_feature]
669
663
 
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"""
677
671
 
678
 
    _test_needs_features = [CompiledDirstateHelpersFeature]
 
672
    _test_needs_features = [compiled_dirstate_helpers_feature]
679
673
 
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"""
765
759
 
766
 
    _test_needs_features = [CompiledDirstateHelpersFeature]
 
760
    _test_needs_features = [compiled_dirstate_helpers_feature]
767
761
 
768
762
    def get_read_dirblocks(self):
769
763
        from bzrlib._dirstate_helpers_pyx import _read_dirblocks
779
773
    """
780
774
 
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
784
778
        else:
785
779
            from bzrlib._dirstate_helpers_py import bisect_dirblock
786
780
        self.assertIs(bisect_dirblock, dirstate.bisect_dirblock)
787
781
 
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
791
785
        else:
792
786
            from bzrlib._dirstate_helpers_py import _bisect_path_left
793
787
        self.assertIs(_bisect_path_left, dirstate._bisect_path_left)
794
788
 
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
798
792
        else:
799
793
            from bzrlib._dirstate_helpers_py import _bisect_path_right
800
794
        self.assertIs(_bisect_path_right, dirstate._bisect_path_right)
801
795
 
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
805
799
        else:
806
800
            from bzrlib._dirstate_helpers_py import cmp_by_dirs
807
801
        self.assertIs(cmp_by_dirs, dirstate.cmp_by_dirs)
808
802
 
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
812
806
        else:
813
807
            from bzrlib._dirstate_helpers_py import _read_dirblocks
814
808
        self.assertIs(_read_dirblocks, dirstate._read_dirblocks)
815
809
 
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
819
813
        else:
820
814
            from bzrlib.dirstate import update_entry
821
815
        self.assertIs(update_entry, dirstate.update_entry)
822
816
 
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)
827
821
        else: