bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2006 Canonical Ltd
|
|
1534.1.29
by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository. |
2 |
# Authors: Robert Collins <robert.collins@canonical.com>
|
3 |
# -*- coding: utf-8 -*-
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
4 |
#
|
|
1534.1.29
by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository. |
5 |
# This program is free software; you can redistribute it and/or modify
|
6 |
# it under the terms of the GNU General Public License as published by
|
|
7 |
# the Free Software Foundation; either version 2 of the License, or
|
|
8 |
# (at your option) any later version.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
9 |
#
|
|
1534.1.29
by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository. |
10 |
# This program is distributed in the hope that it will be useful,
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
# GNU General Public License for more details.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
14 |
#
|
|
1534.1.29
by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository. |
15 |
# You should have received a copy of the GNU General Public License
|
16 |
# along with this program; if not, write to the Free Software
|
|
17 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 |
||
19 |
||
20 |
"""InterRepository implementation tests for bzr.
|
|
21 |
||
22 |
These test the conformance of all the interrepository variations to the
|
|
23 |
expected API including generally applicable corner cases.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
24 |
Specific tests for individual formats are in the tests/test_repository.py file
|
|
1534.1.29
by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository. |
25 |
rather than in tests/interrepository_implementations/*.py.
|
26 |
"""
|
|
27 |
||
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
28 |
|
29 |
from bzrlib.errors import ( |
|
30 |
FileExists, |
|
31 |
UninitializableFormat, |
|
32 |
)
|
|
33 |
||
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
34 |
from bzrlib.repository import ( |
|
2998.2.2
by John Arbash Meinel
implement a faster path for copying from packs back to knits. |
35 |
InterKnitRepo, |
|
2553.2.4
by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter |
36 |
InterRepository, |
37 |
)
|
|
|
1534.1.29
by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository. |
38 |
from bzrlib.tests import ( |
39 |
default_transport, |
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
40 |
multiply_tests, |
|
1534.1.29
by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository. |
41 |
)
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
42 |
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir |
43 |
from bzrlib.transport import get_transport |
|
|
1534.1.29
by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository. |
44 |
|
45 |
||
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
46 |
def make_scenarios(transport_server, transport_readonly_server, formats): |
47 |
"""Transform the input formats to a list of scenarios. |
|
|
2553.2.4
by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter |
48 |
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
49 |
:param formats: A list of tuples:
|
50 |
(interrepo_class, repository_format, repository_format_to).
|
|
|
2553.2.4
by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter |
51 |
"""
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
52 |
result = [] |
53 |
for interrepo_class, repository_format, repository_format_to in formats: |
|
54 |
id = '%s,%s,%s' % (interrepo_class.__name__, |
|
55 |
repository_format.__class__.__name__, |
|
56 |
repository_format_to.__class__.__name__) |
|
57 |
scenario = (id, |
|
58 |
{"transport_server": transport_server, |
|
59 |
"transport_readonly_server": transport_readonly_server, |
|
60 |
"repository_format": repository_format, |
|
61 |
"interrepo_class": interrepo_class, |
|
62 |
"repository_format_to": repository_format_to, |
|
63 |
})
|
|
64 |
result.append(scenario) |
|
65 |
return result |
|
66 |
||
67 |
||
68 |
def default_test_list(): |
|
69 |
"""Generate the default list of interrepo permutations to test.""" |
|
70 |
from bzrlib.repofmt import knitrepo, pack_repo, weaverepo |
|
71 |
result = [] |
|
72 |
# test the default InterRepository between format 6 and the current
|
|
73 |
# default format.
|
|
74 |
# XXX: robertc 20060220 reinstate this when there are two supported
|
|
75 |
# formats which do not have an optimal code path between them.
|
|
76 |
#result.append((InterRepository,
|
|
77 |
# RepositoryFormat6(),
|
|
78 |
# RepositoryFormatKnit1()))
|
|
79 |
for optimiser_class in InterRepository._optimisers: |
|
80 |
format_to_test = optimiser_class._get_repo_format_to_test() |
|
81 |
if format_to_test is not None: |
|
82 |
result.append((optimiser_class, |
|
83 |
format_to_test, format_to_test)) |
|
84 |
# if there are specific combinations we want to use, we can add them
|
|
85 |
# here. We want to test rich root upgrading.
|
|
86 |
result.append((InterRepository, |
|
87 |
weaverepo.RepositoryFormat5(), |
|
88 |
knitrepo.RepositoryFormatKnit3())) |
|
89 |
result.append((InterRepository, |
|
90 |
knitrepo.RepositoryFormatKnit1(), |
|
91 |
knitrepo.RepositoryFormatKnit3())) |
|
92 |
result.append((InterRepository, |
|
93 |
knitrepo.RepositoryFormatKnit1(), |
|
94 |
knitrepo.RepositoryFormatKnit3())) |
|
95 |
result.append((InterKnitRepo, |
|
96 |
knitrepo.RepositoryFormatKnit1(), |
|
97 |
pack_repo.RepositoryFormatKnitPack1())) |
|
98 |
result.append((InterKnitRepo, |
|
99 |
pack_repo.RepositoryFormatKnitPack1(), |
|
100 |
knitrepo.RepositoryFormatKnit1())) |
|
101 |
result.append((InterKnitRepo, |
|
102 |
knitrepo.RepositoryFormatKnit3(), |
|
103 |
pack_repo.RepositoryFormatKnitPack3())) |
|
104 |
result.append((InterKnitRepo, |
|
105 |
pack_repo.RepositoryFormatKnitPack3(), |
|
106 |
knitrepo.RepositoryFormatKnit3())) |
|
107 |
result.append((InterKnitRepo, |
|
108 |
pack_repo.RepositoryFormatKnitPack3(), |
|
109 |
pack_repo.RepositoryFormatKnitPack4())) |
|
110 |
return result |
|
|
2553.2.4
by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter |
111 |
|
112 |
||
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
113 |
class TestCaseWithInterRepository(TestCaseWithBzrDir): |
114 |
||
115 |
def setUp(self): |
|
116 |
super(TestCaseWithInterRepository, self).setUp() |
|
117 |
||
118 |
def make_branch(self, relpath, format=None): |
|
119 |
repo = self.make_repository(relpath, format=format) |
|
120 |
return repo.bzrdir.create_branch() |
|
121 |
||
122 |
def make_bzrdir(self, relpath, format=None): |
|
123 |
try: |
|
124 |
url = self.get_url(relpath) |
|
125 |
segments = url.split('/') |
|
126 |
if segments and segments[-1] not in ('', '.'): |
|
127 |
parent = '/'.join(segments[:-1]) |
|
128 |
t = get_transport(parent) |
|
129 |
try: |
|
130 |
t.mkdir(segments[-1]) |
|
131 |
except FileExists: |
|
132 |
pass
|
|
133 |
if format is None: |
|
134 |
format = self.repository_format._matchingbzrdir |
|
135 |
return format.initialize(url) |
|
136 |
except UninitializableFormat: |
|
137 |
raise TestSkipped("Format %s is not initializable." % format) |
|
138 |
||
139 |
def make_repository(self, relpath, format=None): |
|
140 |
made_control = self.make_bzrdir(relpath, format=format) |
|
141 |
return self.repository_format.initialize(made_control) |
|
142 |
||
143 |
def make_to_repository(self, relpath): |
|
144 |
made_control = self.make_bzrdir(relpath, |
|
145 |
self.repository_format_to._matchingbzrdir) |
|
146 |
return self.repository_format_to.initialize(made_control) |
|
147 |
||
148 |
||
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
149 |
def load_tests(standard_tests, module, loader): |
150 |
submod_tests = loader.loadTestsFromModuleNames([ |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
151 |
'bzrlib.tests.interrepository_implementations.test_fetch', |
|
1534.1.29
by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository. |
152 |
'bzrlib.tests.interrepository_implementations.test_interrepository', |
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
153 |
])
|
154 |
scenarios = make_scenarios( |
|
|
1534.1.29
by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository. |
155 |
default_transport, |
156 |
# None here will cause a readonly decorator to be created
|
|
157 |
# by the TestCaseWithTransport.get_readonly_transport method.
|
|
158 |
None, |
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
159 |
default_test_list() |
|
1534.1.29
by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository. |
160 |
)
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
161 |
return multiply_tests(submod_tests, scenarios, standard_tests) |