/brz/remove-bazaar

To get this branch, use:
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(
2671.1.1 by Andrew Bennetts
Add support for comparing Repositories with == and != operators.
94
                relpath, format=format)
2485.7.1 by Robert Collins
Relocate TestCaseWithRepository to be more central.
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',
2696.3.2 by Martin Pool
Move some per-repository tests from big test_repository to test_fetch
103
        'bzrlib.tests.repository_implementations.test_fetch',
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
104
        'bzrlib.tests.repository_implementations.test_fileid_involved',
2671.1.5 by Andrew Bennetts
Move has_same_location tests to a new file.
105
        'bzrlib.tests.repository_implementations.test_has_same_location',
2249.5.18 by John Arbash Meinel
Add tests for iter_reverse_revision_history
106
        'bzrlib.tests.repository_implementations.test_iter_reverse_revision_history',
2604.2.1 by Robert Collins
(robertc) Introduce a pack command.
107
        'bzrlib.tests.repository_implementations.test_pack',
1570.1.2 by Robert Collins
Import bzrtools' 'fix' command as 'bzr reconcile.'
108
        'bzrlib.tests.repository_implementations.test_reconcile',
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
109
        'bzrlib.tests.repository_implementations.test_repository',
1913.1.1 by John Arbash Meinel
Fix bug #55783
110
        '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).
111
        'bzrlib.tests.repository_implementations.test_statistics',
2617.6.1 by Robert Collins
* New method on Repository - ``start_write_group``, ``end_write_group``
112
        'bzrlib.tests.repository_implementations.test_write_group',
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
113
        ]
1752.2.31 by Martin Pool
[broken] some support for write operations over hpss
114
2018.5.30 by Robert Collins
Reenable the stock repository implementations for testing.
115
    from bzrlib.smart.server import (
116
        SmartTCPServer_for_testing,
117
        ReadonlySmartTCPServer_for_testing,
118
        )
1752.2.31 by Martin Pool
[broken] some support for write operations over hpss
119
    from bzrlib.remote import RemoteBzrDirFormat, RemoteRepositoryFormat
2018.5.30 by Robert Collins
Reenable the stock repository implementations for testing.
120
2241.1.11 by Martin Pool
Get rid of RepositoryFormat*_instance objects. Instead the format
121
    registry = repository.format_registry
122
    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.
123
    all_formats.extend(weaverepo._legacy_formats)
2018.5.30 by Robert Collins
Reenable the stock repository implementations for testing.
124
    adapter = RepositoryTestProviderAdapter(
125
        default_transport,
126
        # None here will cause a readonly decorator to be created
127
        # by the TestCaseWithTransport.get_readonly_transport method.
128
        None,
2241.1.1 by Martin Pool
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary
129
        [(format, format._matchingbzrdir) for format in all_formats])
2018.5.30 by Robert Collins
Reenable the stock repository implementations for testing.
130
    loader = TestLoader()
131
    adapt_modules(test_repository_implementations, adapter, loader, result)
132
133
    adapt_to_smart_server = RepositoryTestProviderAdapter(
134
        SmartTCPServer_for_testing,
135
        ReadonlySmartTCPServer_for_testing,
2018.5.66 by Wouter van Heyst
Fix repository test parameterization for RemoteRepository.
136
        [(RemoteRepositoryFormat(), RemoteBzrDirFormat())],
137
        MemoryServer
138
        )
1752.2.31 by Martin Pool
[broken] some support for write operations over hpss
139
    adapt_modules(test_repository_implementations,
2018.5.30 by Robert Collins
Reenable the stock repository implementations for testing.
140
                  adapt_to_smart_server,
141
                  loader,
142
                  result)
1752.2.33 by Martin Pool
[broken] more hpss methods and adapt to bzrdir tests
143
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
144
    return result