/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
1
# Copyright (C) 2008, 2009 Canonical Ltd
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
3735.36.3 by John Arbash Meinel
Add the new address for FSF to the new files.
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
16
17
18
"""Repository implementation tests for CHK support.
19
20
These tests check the conformance of the chk index some repositories support.
21
All repository formats are tested - those that do not suppport chk indices
22
have the test_unsupported tests run; the others have the test_supported tests
23
run.
24
"""
25
26
from bzrlib import (
27
    repository,
28
    remote,
29
    )
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
30
from bzrlib.repofmt.pack_repo import (
31
    RepositoryFormatKnitPack5,
4241.6.8 by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil)
32
    )
33
from bzrlib.repofmt.groupcompress_repo import (
5546.1.1 by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2.
34
    RepositoryFormat2a,
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
35
    )
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
36
from bzrlib.tests import (
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
37
    multiply_tests,
38
    )
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
39
from bzrlib.tests.per_repository import (
40
    all_repository_format_scenarios,
41
    TestCaseWithRepository,
42
    )
43
44
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
45
class TestCaseWithRepositoryCHK(TestCaseWithRepository):
46
4634.35.10 by Andrew Bennetts
Move tests to per_repository_chk.
47
    def make_repository(self, path, format=None):
48
        TestCaseWithRepository.make_repository(self, path, format=format)
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
49
        return repository.Repository.open(self.get_transport(path).base)
50
51
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
52
def load_tests(standard_tests, module, loader):
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
53
    supported_scenarios = []
54
    unsupported_scenarios = []
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
55
    for test_name, scenario_info in all_repository_format_scenarios():
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
56
        format = scenario_info['repository_format']
57
        # For remote repositories, we test both with, and without a backing chk
58
        # capable format: change the format we use to create the repo to direct
59
        # formats, and then the overridden make_repository in
3735.2.7 by Robert Collins
Explanations.
60
        # TestCaseWithRepositoryCHK will give a re-opened RemoteRepository
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
61
        # with the chosen backing format.
62
        if isinstance(format, remote.RemoteRepositoryFormat):
63
            with_support = dict(scenario_info)
5546.1.1 by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2.
64
            with_support['repository_format'] = RepositoryFormat2a()
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
65
            supported_scenarios.append((test_name + "(Supported)", with_support))
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
66
            no_support = dict(scenario_info)
67
            no_support['repository_format'] = RepositoryFormatKnitPack5()
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
68
            unsupported_scenarios.append((test_name + "(Not Supported)", no_support))
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
69
        elif format.supports_chks:
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
70
            supported_scenarios.append((test_name, scenario_info))
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
71
        else:
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
72
            unsupported_scenarios.append((test_name, scenario_info))
73
    result = loader.suiteClass()
74
    supported_tests = loader.loadTestsFromModuleNames([
75
        'bzrlib.tests.per_repository_chk.test_supported'])
76
    unsupported_tests = loader.loadTestsFromModuleNames([
77
        'bzrlib.tests.per_repository_chk.test_unsupported'])
78
    multiply_tests(supported_tests, supported_scenarios, result)
79
    multiply_tests(unsupported_tests, unsupported_scenarios, result)
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
80
    return result