bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2241.1.1
by Martin Pool
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary |
1 |
# Copyright (C) 2006, 2007 Canonical Ltd
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
2 |
# Authors: Robert Collins <robert.collins@canonical.com>
|
|
2241.1.1
by Martin Pool
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary |
3 |
# and others
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
4 |
#
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
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.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
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.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
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 |
||
|
1904.2.5
by Martin Pool
Fix format warning inside test suite and add test |
20 |
"""Repository implementation tests for bzr.
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
21 |
|
22 |
These test the conformance of all the repository variations to the expected API.
|
|
23 |
Specific tests for individual formats are in the tests/test_repository.py file
|
|
24 |
rather than in tests/branch_implementations/*.py.
|
|
25 |
"""
|
|
26 |
||
|
2241.1.2
by Martin Pool
change to using external Repository format registry |
27 |
from bzrlib import ( |
28 |
repository, |
|
29 |
)
|
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
30 |
from bzrlib.repofmt import ( |
31 |
weaverepo, |
|
32 |
)
|
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
33 |
from bzrlib.tests import ( |
34 |
adapt_modules, |
|
35 |
default_transport, |
|
|
2553.2.3
by Robert Collins
Split out the common test scenario support from the repository implementation specific code. |
36 |
TestScenarioApplier, |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
37 |
TestLoader, |
38 |
TestSuite, |
|
39 |
)
|
|
|
2485.7.1
by Robert Collins
Relocate TestCaseWithRepository to be more central. |
40 |
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir |
|
2018.5.66
by Wouter van Heyst
Fix repository test parameterization for RemoteRepository. |
41 |
from bzrlib.transport.memory import MemoryServer |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
42 |
|
43 |
||
|
2553.2.3
by Robert Collins
Split out the common test scenario support from the repository implementation specific code. |
44 |
class RepositoryTestProviderAdapter(TestScenarioApplier): |
|
2553.2.2
by Robert Collins
Move RepositoryTestProviderAdapter into the tests part of the code base. |
45 |
"""A tool to generate a suite testing multiple repository formats at once. |
46 |
||
47 |
This is done by copying the test once for each transport and injecting
|
|
48 |
the transport_server, transport_readonly_server, and bzrdir_format and
|
|
49 |
repository_format classes into each copy. Each copy is also given a new id()
|
|
50 |
to make it easy to identify.
|
|
51 |
"""
|
|
52 |
||
53 |
def __init__(self, transport_server, transport_readonly_server, formats, |
|
54 |
vfs_transport_factory=None): |
|
|
2553.2.3
by Robert Collins
Split out the common test scenario support from the repository implementation specific code. |
55 |
TestScenarioApplier.__init__(self) |
|
2553.2.2
by Robert Collins
Move RepositoryTestProviderAdapter into the tests part of the code base. |
56 |
self._transport_server = transport_server |
57 |
self._transport_readonly_server = transport_readonly_server |
|
58 |
self._vfs_transport_factory = vfs_transport_factory |
|
59 |
self.scenarios = self.formats_to_scenarios(formats) |
|
60 |
||
61 |
def formats_to_scenarios(self, formats): |
|
62 |
"""Transform the input formats to a list of scenarios. |
|
63 |
||
64 |
:param formats: A list of (repository_format, bzrdir_format).
|
|
65 |
"""
|
|
66 |
result = [] |
|
67 |
for repository_format, bzrdir_format in formats: |
|
68 |
scenario = (repository_format.__class__.__name__, |
|
69 |
{"transport_server":self._transport_server, |
|
70 |
"transport_readonly_server":self._transport_readonly_server, |
|
71 |
"bzrdir_format":bzrdir_format, |
|
72 |
"repository_format":repository_format, |
|
73 |
})
|
|
74 |
# Only override the test's vfs_transport_factory if one was
|
|
75 |
# specified, otherwise just leave the default in place.
|
|
76 |
if self._vfs_transport_factory: |
|
77 |
scenario[1]['vfs_transport_factory'] = self._vfs_transport_factory |
|
78 |
result.append(scenario) |
|
79 |
return result |
|
80 |
||
81 |
||
|
2485.7.1
by Robert Collins
Relocate TestCaseWithRepository to be more central. |
82 |
class TestCaseWithRepository(TestCaseWithBzrDir): |
83 |
||
84 |
def make_repository(self, relpath, format=None): |
|
85 |
if format is None: |
|
86 |
# Create a repository of the type we are trying to test.
|
|
87 |
made_control = self.make_bzrdir(relpath) |
|
|
2553.2.1
by Robert Collins
Overhaul RepositoryTestAdapter to be cleaner and more modular. |
88 |
repo = self.repository_format.initialize(made_control) |
|
2553.2.2
by Robert Collins
Move RepositoryTestProviderAdapter into the tests part of the code base. |
89 |
if getattr(self, "repository_to_test_repository", None): |
|
2553.2.1
by Robert Collins
Overhaul RepositoryTestAdapter to be cleaner and more modular. |
90 |
repo = self.repository_to_test_repository(repo) |
91 |
return repo |
|
|
2485.7.1
by Robert Collins
Relocate TestCaseWithRepository to be more central. |
92 |
else: |
93 |
return super(TestCaseWithRepository, self).make_repository( |
|
94 |
relpath, format) |
|
95 |
||
96 |
||
97 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
98 |
def test_suite(): |
99 |
result = TestSuite() |
|
100 |
test_repository_implementations = [ |
|
|
1687.1.7
by Robert Collins
Teach Repository about break_lock. |
101 |
'bzrlib.tests.repository_implementations.test_break_lock', |
|
1740.3.1
by Jelmer Vernooij
Introduce and use CommitBuilder objects. |
102 |
'bzrlib.tests.repository_implementations.test_commit_builder', |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
103 |
'bzrlib.tests.repository_implementations.test_fileid_involved', |
|
2249.5.18
by John Arbash Meinel
Add tests for iter_reverse_revision_history |
104 |
'bzrlib.tests.repository_implementations.test_iter_reverse_revision_history', |
|
2604.2.1
by Robert Collins
(robertc) Introduce a pack command. |
105 |
'bzrlib.tests.repository_implementations.test_pack', |
|
1570.1.2
by Robert Collins
Import bzrtools' 'fix' command as 'bzr reconcile.' |
106 |
'bzrlib.tests.repository_implementations.test_reconcile', |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
107 |
'bzrlib.tests.repository_implementations.test_repository', |
|
1913.1.1
by John Arbash Meinel
Fix bug #55783 |
108 |
'bzrlib.tests.repository_implementations.test_revision', |
|
2258.1.1
by Robert Collins
Move info branch statistics gathering into the repository to allow smart server optimisation (Robert Collins). |
109 |
'bzrlib.tests.repository_implementations.test_statistics', |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
110 |
]
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
111 |
|
|
2018.5.30
by Robert Collins
Reenable the stock repository implementations for testing. |
112 |
from bzrlib.smart.server import ( |
113 |
SmartTCPServer_for_testing, |
|
114 |
ReadonlySmartTCPServer_for_testing, |
|
115 |
)
|
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
116 |
from bzrlib.remote import RemoteBzrDirFormat, RemoteRepositoryFormat |
|
2018.5.30
by Robert Collins
Reenable the stock repository implementations for testing. |
117 |
|
|
2241.1.11
by Martin Pool
Get rid of RepositoryFormat*_instance objects. Instead the format |
118 |
registry = repository.format_registry |
119 |
all_formats = [registry.get(k) for k in registry.keys()] |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
120 |
all_formats.extend(weaverepo._legacy_formats) |
|
2018.5.30
by Robert Collins
Reenable the stock repository implementations for testing. |
121 |
adapter = RepositoryTestProviderAdapter( |
122 |
default_transport, |
|
123 |
# None here will cause a readonly decorator to be created
|
|
124 |
# by the TestCaseWithTransport.get_readonly_transport method.
|
|
125 |
None, |
|
|
2241.1.1
by Martin Pool
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary |
126 |
[(format, format._matchingbzrdir) for format in all_formats]) |
|
2018.5.30
by Robert Collins
Reenable the stock repository implementations for testing. |
127 |
loader = TestLoader() |
128 |
adapt_modules(test_repository_implementations, adapter, loader, result) |
|
129 |
||
130 |
adapt_to_smart_server = RepositoryTestProviderAdapter( |
|
131 |
SmartTCPServer_for_testing, |
|
132 |
ReadonlySmartTCPServer_for_testing, |
|
|
2018.5.66
by Wouter van Heyst
Fix repository test parameterization for RemoteRepository. |
133 |
[(RemoteRepositoryFormat(), RemoteBzrDirFormat())], |
134 |
MemoryServer
|
|
135 |
)
|
|
|
1752.2.31
by Martin Pool
[broken] some support for write operations over hpss |
136 |
adapt_modules(test_repository_implementations, |
|
2018.5.30
by Robert Collins
Reenable the stock repository implementations for testing. |
137 |
adapt_to_smart_server, |
138 |
loader, |
|
139 |
result) |
|
|
1752.2.33
by Martin Pool
[broken] more hpss methods and adapt to bzrdir tests |
140 |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
141 |
return result |