bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
5147.2.1
by Vincent Ladeuil
Failing tests for bug #519319. |
1 |
# Copyright (C) 2009, 2010 Canonical Ltd
|
|
3920.2.7
by Jelmer Vernooij
Add comments about dummy vcs. |
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
|
|
|
3920.2.28
by Jelmer Vernooij
Fix FSF address. |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
3920.2.7
by Jelmer Vernooij
Add comments about dummy vcs. |
16 |
|
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
17 |
|
|
3920.2.7
by Jelmer Vernooij
Add comments about dummy vcs. |
18 |
"""Black-box tests for bzr dpush."""
|
19 |
||
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
20 |
|
|
3920.2.30
by Jelmer Vernooij
Review from John. |
21 |
import os |
22 |
||
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
23 |
from bzrlib import ( |
24 |
branch, |
|
25 |
bzrdir, |
|
26 |
foreign, |
|
27 |
tests, |
|
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
28 |
workingtree, |
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
29 |
)
|
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
30 |
from bzrlib.tests import ( |
31 |
blackbox, |
|
32 |
test_foreign, |
|
33 |
)
|
|
|
4721.2.6
by Vincent Ladeuil
More agressive test sharing between push and dpush. |
34 |
from bzrlib.tests.blackbox import test_push |
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
35 |
|
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
36 |
|
37 |
def load_tests(standard_tests, module, loader): |
|
38 |
"""Multiply tests for the dpush command.""" |
|
39 |
result = loader.suiteClass() |
|
40 |
||
41 |
# one for each king of change
|
|
42 |
changes_tests, remaining_tests = tests.split_suite_by_condition( |
|
43 |
standard_tests, tests.condition_isinstance(( |
|
44 |
TestDpushStrictWithChanges, |
|
45 |
)))
|
|
46 |
changes_scenarios = [ |
|
47 |
('uncommitted', |
|
48 |
dict(_changes_type= '_uncommitted_changes')), |
|
49 |
('pending-merges', |
|
50 |
dict(_changes_type= '_pending_merges')), |
|
51 |
('out-of-sync-trees', |
|
52 |
dict(_changes_type= '_out_of_sync_trees')), |
|
53 |
]
|
|
54 |
tests.multiply_tests(changes_tests, changes_scenarios, result) |
|
55 |
# No parametrization for the remaining tests
|
|
56 |
result.addTests(remaining_tests) |
|
57 |
||
58 |
return result |
|
59 |
||
60 |
||
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
61 |
class TestDpush(blackbox.ExternalBase): |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
62 |
|
63 |
def setUp(self): |
|
64 |
super(TestDpush, self).setUp() |
|
|
4721.2.5
by Vincent Ladeuil
Some refactoring. |
65 |
test_foreign.register_dummy_foreign_for_test(self) |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
66 |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
67 |
def make_dummy_builder(self, relpath): |
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
68 |
builder = self.make_branch_builder( |
69 |
relpath, format=test_foreign.DummyForeignVcsDirFormat()) |
|
70 |
builder.build_snapshot('revid', None, |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
71 |
[('add', ('', 'TREE_ROOT', 'directory', None)), |
72 |
('add', ('foo', 'fooid', 'file', 'bar'))]) |
|
73 |
return builder |
|
74 |
||
|
3920.2.18
by Jelmer Vernooij
make sure dpush between native branches fails. |
75 |
def test_dpush_native(self): |
|
3920.2.30
by Jelmer Vernooij
Review from John. |
76 |
target_tree = self.make_branch_and_tree("dp") |
77 |
source_tree = self.make_branch_and_tree("dc") |
|
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
78 |
output, error = self.run_bzr("dpush -d dc dp", retcode=3) |
79 |
self.assertEquals("", output) |
|
|
4368.2.2
by Jelmer Vernooij
s/not possible/not necessary/. |
80 |
self.assertContainsRe(error, 'in the same VCS, lossy push not necessary. Please use regular push.') |
|
3920.2.18
by Jelmer Vernooij
make sure dpush between native branches fails. |
81 |
|
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
82 |
def test_dpush(self): |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
83 |
branch = self.make_dummy_builder('d').get_branch() |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
84 |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
85 |
dc = branch.bzrdir.sprout('dc', force_new_repo=True) |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
86 |
self.build_tree(("dc/foo", "blaaaa")) |
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
87 |
dc.open_workingtree().commit('msg') |
88 |
||
|
4347.3.1
by Jelmer Vernooij
Return BranchPushResult instance from lossy_push() and make dpush print |
89 |
output, error = self.run_bzr("dpush -d dc d") |
90 |
self.assertEquals(error, "Pushed up to revision 2.\n") |
|
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
91 |
self.check_output("", "status dc") |
92 |
||
93 |
def test_dpush_new(self): |
|
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
94 |
b = self.make_dummy_builder('d').get_branch() |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
95 |
|
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
96 |
dc = b.bzrdir.sprout('dc', force_new_repo=True) |
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
97 |
self.build_tree_contents([("dc/foofile", "blaaaa")]) |
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
98 |
dc_tree = dc.open_workingtree() |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
99 |
dc_tree.add("foofile") |
100 |
dc_tree.commit("msg") |
|
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
101 |
|
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
102 |
self.check_output("", "dpush -d dc d") |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
103 |
self.check_output("2\n", "revno dc") |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
104 |
self.check_output("", "status dc") |
105 |
||
106 |
def test_dpush_wt_diff(self): |
|
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
107 |
b = self.make_dummy_builder('d').get_branch() |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
108 |
|
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
109 |
dc = b.bzrdir.sprout('dc', force_new_repo=True) |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
110 |
self.build_tree_contents([("dc/foofile", "blaaaa")]) |
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
111 |
dc_tree = dc.open_workingtree() |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
112 |
dc_tree.add("foofile") |
113 |
newrevid = dc_tree.commit('msg') |
|
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
114 |
|
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
115 |
self.build_tree_contents([("dc/foofile", "blaaaal")]) |
|
4721.2.3
by Vincent Ladeuil
Make all test pass by implement --strict for dpush. |
116 |
self.check_output("", "dpush -d dc d --no-strict") |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
117 |
self.assertFileEqual("blaaaal", "dc/foofile") |
|
4721.2.3
by Vincent Ladeuil
Make all test pass by implement --strict for dpush. |
118 |
# if the dummy vcs wasn't that dummy we could uncomment the line below
|
119 |
# self.assertFileEqual("blaaaa", "d/foofile")
|
|
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
120 |
self.check_output('modified:\n foofile\n', "status dc") |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
121 |
|
122 |
def test_diverged(self): |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
123 |
builder = self.make_dummy_builder('d') |
124 |
||
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
125 |
b = builder.get_branch() |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
126 |
|
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
127 |
dc = b.bzrdir.sprout('dc', force_new_repo=True) |
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
128 |
dc_tree = dc.open_workingtree() |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
129 |
|
130 |
self.build_tree_contents([("dc/foo", "bar")]) |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
131 |
dc_tree.commit('msg1') |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
132 |
|
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
133 |
builder.build_snapshot('revid2', None, |
134 |
[('modify', ('fooid', 'blie'))]) |
|
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
135 |
|
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
136 |
output, error = self.run_bzr("dpush -d dc d", retcode=3) |
137 |
self.assertEquals(output, "") |
|
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
138 |
self.assertContainsRe(error, "have diverged") |
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
139 |
|
140 |
||
141 |
class TestDpushStrictMixin(object): |
|
142 |
||
|
4721.2.7
by Vincent Ladeuil
Final tweak. |
143 |
def setUp(self): |
144 |
test_foreign.register_dummy_foreign_for_test(self) |
|
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
145 |
# Create an empty branch where we will be able to push
|
146 |
self.foreign = self.make_branch( |
|
|
4721.2.7
by Vincent Ladeuil
Final tweak. |
147 |
'to', format=test_foreign.DummyForeignVcsDirFormat()) |
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
148 |
|
|
4721.2.6
by Vincent Ladeuil
More agressive test sharing between push and dpush. |
149 |
def set_config_push_strict(self, value): |
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
150 |
# set config var (any of bazaar.conf, locations.conf, branch.conf
|
151 |
# should do)
|
|
152 |
conf = self.tree.branch.get_config() |
|
153 |
conf.set_user_option('dpush_strict', value) |
|
154 |
||
155 |
_default_command = ['dpush', '../to'] |
|
156 |
||
157 |
||
|
4721.2.6
by Vincent Ladeuil
More agressive test sharing between push and dpush. |
158 |
class TestDpushStrictWithoutChanges(TestDpushStrictMixin, |
159 |
test_push.TestPushStrictWithoutChanges): |
|
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
160 |
|
161 |
def setUp(self): |
|
|
4721.2.7
by Vincent Ladeuil
Final tweak. |
162 |
test_push.TestPushStrictWithoutChanges.setUp(self) |
163 |
TestDpushStrictMixin.setUp(self) |
|
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
164 |
|
|
4721.2.6
by Vincent Ladeuil
More agressive test sharing between push and dpush. |
165 |
|
166 |
class TestDpushStrictWithChanges(TestDpushStrictMixin, |
|
167 |
test_push.TestPushStrictWithChanges): |
|
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
168 |
|
169 |
_changes_type = None # Set by load_tests |
|
170 |
||
171 |
def setUp(self): |
|
|
4721.2.7
by Vincent Ladeuil
Final tweak. |
172 |
test_push.TestPushStrictWithChanges.setUp(self) |
173 |
TestDpushStrictMixin.setUp(self) |
|
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
174 |
|
|
4721.2.6
by Vincent Ladeuil
More agressive test sharing between push and dpush. |
175 |
def test_push_with_revision(self): |
176 |
raise tests.TestNotApplicable('dpush does not handle --revision') |
|
177 |