1
# Copyright (C) 2008, 2009 Canonical Ltd
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.
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.
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
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
"""Repository implementation tests for CHK support.
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
30
from bzrlib.repofmt.pack_repo import (
31
RepositoryFormatKnitPack5,
33
from bzrlib.repofmt.groupcompress_repo import (
36
from bzrlib.tests import (
39
from bzrlib.tests.per_repository import (
40
all_repository_format_scenarios,
41
TestCaseWithRepository,
45
class TestCaseWithRepositoryCHK(TestCaseWithRepository):
47
def make_repository(self, path, format=None):
48
TestCaseWithRepository.make_repository(self, path, format=format)
49
return repository.Repository.open(self.get_transport(path).base)
52
def load_tests(standard_tests, module, loader):
53
supported_scenarios = []
54
unsupported_scenarios = []
55
for test_name, scenario_info in all_repository_format_scenarios():
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
60
# TestCaseWithRepositoryCHK will give a re-opened RemoteRepository
61
# with the chosen backing format.
62
if isinstance(format, remote.RemoteRepositoryFormat):
63
with_support = dict(scenario_info)
64
with_support['repository_format'] = RepositoryFormatCHK1()
65
supported_scenarios.append((test_name + "(Supported)", with_support))
66
no_support = dict(scenario_info)
67
no_support['repository_format'] = RepositoryFormatKnitPack5()
68
unsupported_scenarios.append((test_name + "(Not Supported)", no_support))
69
elif format.supports_chks:
70
supported_scenarios.append((test_name, scenario_info))
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)