~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/interrepository_implementations/__init__.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
"""
27
27
 
28
28
from bzrlib.repository import (
29
 
    InterRepositoryTestProviderAdapter,
30
 
    )
31
 
                            
 
29
                               InterRepository,
 
30
                               InterModel1and2,
 
31
                               InterKnit1and2,
 
32
                               )
32
33
from bzrlib.tests import (
33
34
                          adapt_modules,
34
35
                          default_transport,
35
36
                          TestLoader,
 
37
                          TestScenarioApplier,
36
38
                          TestSuite,
37
39
                          )
38
40
 
39
41
 
 
42
class InterRepositoryTestProviderAdapter(TestScenarioApplier):
 
43
    """A tool to generate a suite testing multiple inter repository formats.
 
44
 
 
45
    This is done by copying the test once for each interrepo provider and injecting
 
46
    the transport_server, transport_readonly_server, repository_format and 
 
47
    repository_to_format classes into each copy.
 
48
    Each copy is also given a new id() to make it easy to identify.
 
49
    """
 
50
 
 
51
    def __init__(self, transport_server, transport_readonly_server, formats):
 
52
        TestScenarioApplier.__init__(self)
 
53
        self._transport_server = transport_server
 
54
        self._transport_readonly_server = transport_readonly_server
 
55
        self.scenarios = self.formats_to_scenarios(formats)
 
56
    
 
57
    def formats_to_scenarios(self, formats):
 
58
        """Transform the input formats to a list of scenarios.
 
59
 
 
60
        :param formats: A list of tuples:
 
61
            (interrepo_class, repository_format, repository_format_to).
 
62
        """
 
63
        result = []
 
64
        for interrepo_class, repository_format, repository_format_to in formats:
 
65
            scenario = (interrepo_class.__name__,
 
66
                {"transport_server":self._transport_server,
 
67
                 "transport_readonly_server":self._transport_readonly_server,
 
68
                 "repository_format":repository_format,
 
69
                 "interrepo_class":interrepo_class,
 
70
                 "repository_format_to":repository_format_to,
 
71
                 })
 
72
            result.append(scenario)
 
73
        return result
 
74
    
 
75
    @staticmethod
 
76
    def default_test_list():
 
77
        """Generate the default list of interrepo permutations to test."""
 
78
        from bzrlib.repofmt import knitrepo, weaverepo
 
79
        result = []
 
80
        # test the default InterRepository between format 6 and the current 
 
81
        # default format.
 
82
        # XXX: robertc 20060220 reinstate this when there are two supported
 
83
        # formats which do not have an optimal code path between them.
 
84
        #result.append((InterRepository,
 
85
        #               RepositoryFormat6(),
 
86
        #               RepositoryFormatKnit1()))
 
87
        for optimiser_class in InterRepository._optimisers:
 
88
            format_to_test = optimiser_class._get_repo_format_to_test()
 
89
            if format_to_test is not None:
 
90
                result.append((optimiser_class,
 
91
                               format_to_test, format_to_test))
 
92
        # if there are specific combinations we want to use, we can add them 
 
93
        # here.
 
94
        result.append((InterModel1and2,
 
95
                       weaverepo.RepositoryFormat5(),
 
96
                       knitrepo.RepositoryFormatKnit3()))
 
97
        result.append((InterKnit1and2,
 
98
                       knitrepo.RepositoryFormatKnit1(),
 
99
                       knitrepo.RepositoryFormatKnit3()))
 
100
        return result
 
101
 
 
102
 
40
103
def test_suite():
41
104
    result = TestSuite()
42
105
    test_interrepository_implementations = [