/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/intertree_implementations/__init__.py

  • Committer: Robert Collins
  • Date: 2007-07-04 08:08:13 UTC
  • mfrom: (2572 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20070704080813-wzebx0r88fvwj5rq
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 by Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
35
35
    revision_tree_from_workingtree,
36
36
    TestCaseWithTree,
37
37
    )
 
38
from bzrlib.tests.workingtree_implementations import (
 
39
    WorkingTreeTestProviderAdapter,
 
40
    )
38
41
from bzrlib.tree import InterTree
39
 
from bzrlib.workingtree import (WorkingTreeFormat,
40
 
                                WorkingTreeTestProviderAdapter,
41
 
                                )
 
42
from bzrlib.workingtree import (
 
43
    WorkingTreeFormat3,
 
44
    )
 
45
 
 
46
 
 
47
def return_provided_trees(source, target):
 
48
    """Return the source and target tree unaltered."""
 
49
    return source, target
42
50
 
43
51
 
44
52
class TestCaseWithTwoTrees(TestCaseWithTree):
51
59
        made_control.create_branch()
52
60
        return self.workingtree_format_to.initialize(made_control)
53
61
 
54
 
    def get_to_tree_no_parents_no_content(self, empty_tree):
55
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_no_content(empty_tree, converter=self.workingtree_to_test_tree_to)
56
 
 
57
 
    def get_to_tree_no_parents_abc_content(self, empty_tree):
58
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content(empty_tree, converter=self.workingtree_to_test_tree_to)
59
 
 
60
 
    def get_to_tree_no_parents_abc_content_2(self, empty_tree):
61
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_2(empty_tree, converter=self.workingtree_to_test_tree_to)
62
 
 
63
 
    def get_to_tree_no_parents_abc_content_3(self, empty_tree):
64
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_3(empty_tree, converter=self.workingtree_to_test_tree_to)
65
 
 
66
 
    def get_to_tree_no_parents_abc_content_4(self, empty_tree):
67
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_4(empty_tree, converter=self.workingtree_to_test_tree_to)
68
 
 
69
 
    def get_to_tree_no_parents_abc_content_5(self, empty_tree):
70
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_5(empty_tree, converter=self.workingtree_to_test_tree_to)
71
 
 
72
 
    def get_to_tree_no_parents_abc_content_6(self, empty_tree):
73
 
        return super(TestCaseWithTwoTrees, self).get_tree_no_parents_abc_content_6(empty_tree, converter=self.workingtree_to_test_tree_to)
74
 
 
75
62
 
76
63
class InterTreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
77
64
    """Generate test suites for each InterTree implementation in bzrlib."""
78
65
 
79
 
    def adapt(self, test):
80
 
        result = TestSuite()
 
66
    def formats_to_scenarios(self, formats):
 
67
        """Transform the input formats to a list of scenarios.
 
68
 
 
69
        :param formats: A list of tuples:.
 
70
            (intertree_class,
 
71
             workingtree_format,
 
72
             workingtree_format_to,
 
73
             mutable_trees_to_test_trees)
 
74
        """
 
75
        result = []
81
76
        for (intertree_class,
82
77
            workingtree_format,
83
 
            workingtree_to_test_tree,
84
78
            workingtree_format_to,
85
 
            workingtree_to_test_tree_to) in self._formats:
86
 
            new_test = self._clone_test(
87
 
                test,
88
 
                workingtree_format._matchingbzrdir,
89
 
                workingtree_format,
90
 
                intertree_class.__name__)
91
 
            new_test.intertree_class = intertree_class
92
 
            new_test.workingtree_to_test_tree = workingtree_to_test_tree
93
 
            new_test.workingtree_format_to = workingtree_format_to
94
 
            new_test.workingtree_to_test_tree_to = workingtree_to_test_tree_to
95
 
            result.addTest(new_test)
 
79
            mutable_trees_to_test_trees) in formats:
 
80
            scenario = (intertree_class.__name__, {
 
81
                "transport_server":self._transport_server,
 
82
                "transport_readonly_server":self._transport_readonly_server,
 
83
                "bzrdir_format":workingtree_format._matchingbzrdir,
 
84
                "workingtree_format":workingtree_format,
 
85
                "intertree_class":intertree_class,
 
86
                "workingtree_format_to":workingtree_format_to,
 
87
                # mutable_trees_to_test_trees takes two trees and converts them to,
 
88
                # whatever relationship the optimiser under test requires.,
 
89
                "mutable_trees_to_test_trees":mutable_trees_to_test_trees,
 
90
                # workingtree_to_test_tree is set to disable changing individual,
 
91
                # trees: instead the mutable_trees_to_test_trees helper is used.,
 
92
                "workingtree_to_test_tree":return_parameter,
 
93
                })
 
94
            result.append(scenario)
96
95
        return result
97
96
 
98
97
 
102
101
    # load the tests of the infrastructure for these tests
103
102
    result.addTests(loader.loadTestsFromModuleNames(['bzrlib.tests.intertree_implementations']))
104
103
 
105
 
    default_tree_format = WorkingTreeFormat.get_default_format()
 
104
    default_tree_format = WorkingTreeFormat3()
106
105
    test_intertree_implementations = [
107
106
        'bzrlib.tests.intertree_implementations.test_compare',
108
107
        ]
109
108
    test_intertree_permutations = [
110
109
        # test InterTree with two default-format working trees.
111
 
        (InterTree, default_tree_format, return_parameter,
112
 
         default_tree_format, return_parameter)]
 
110
        (InterTree, default_tree_format, default_tree_format,
 
111
         return_provided_trees)]
113
112
    for optimiser in InterTree._optimisers:
114
113
        test_intertree_permutations.append(
115
114
            (optimiser,
116
 
             optimiser._matching_from_tree_format, optimiser._from_tree_converter,
117
 
             optimiser._matching_to_tree_format, optimiser._to_tree_converter))
 
115
             optimiser._matching_from_tree_format,
 
116
             optimiser._matching_to_tree_format,
 
117
             optimiser._test_mutable_trees_to_test_trees))
118
118
    adapter = InterTreeTestProviderAdapter(
119
119
        default_transport,
120
120
        # None here will cause a readonly decorator to be created