28
28
from bzrlib.repository import (
29
InterRepositoryTestProviderAdapter,
32
33
from bzrlib.tests import (
42
class InterRepositoryTestProviderAdapter(TestScenarioApplier):
43
"""A tool to generate a suite testing multiple inter repository formats.
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.
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)
57
def formats_to_scenarios(self, formats):
58
"""Transform the input formats to a list of scenarios.
60
:param formats: A list of tuples:
61
(interrepo_class, repository_format, repository_format_to).
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,
72
result.append(scenario)
76
def default_test_list():
77
"""Generate the default list of interrepo permutations to test."""
78
from bzrlib.repofmt import knitrepo, weaverepo
80
# test the default InterRepository between format 6 and the current
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
94
result.append((InterModel1and2,
95
weaverepo.RepositoryFormat5(),
96
knitrepo.RepositoryFormatKnit3()))
97
result.append((InterKnit1and2,
98
knitrepo.RepositoryFormatKnit1(),
99
knitrepo.RepositoryFormatKnit3()))
41
104
result = TestSuite()
42
105
test_interrepository_implementations = [