6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2009-2012, 2016 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 |
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
21 |
from bzrlib import ( |
6404.6.1
by Vincent Ladeuil
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. |
22 |
branch, |
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
23 |
tests, |
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
24 |
)
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
25 |
from bzrlib.tests import ( |
5283.4.1
by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts |
26 |
script, |
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
27 |
test_foreign, |
28 |
)
|
|
4721.2.6
by Vincent Ladeuil
More agressive test sharing between push and dpush. |
29 |
from bzrlib.tests.blackbox import test_push |
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
30 |
from bzrlib.tests.scenarios import ( |
31 |
load_tests_apply_scenarios, |
|
32 |
)
|
|
33 |
||
34 |
||
35 |
load_tests = load_tests_apply_scenarios |
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
36 |
|
37 |
||
5283.4.1
by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts |
38 |
class TestDpush(tests.TestCaseWithTransport): |
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
39 |
|
40 |
def setUp(self): |
|
41 |
super(TestDpush, self).setUp() |
|
4721.2.5
by Vincent Ladeuil
Some refactoring. |
42 |
test_foreign.register_dummy_foreign_for_test(self) |
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
43 |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
44 |
def make_dummy_builder(self, relpath): |
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
45 |
builder = self.make_branch_builder( |
46 |
relpath, format=test_foreign.DummyForeignVcsDirFormat()) |
|
47 |
builder.build_snapshot('revid', None, |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
48 |
[('add', ('', 'TREE_ROOT', 'directory', None)), |
49 |
('add', ('foo', 'fooid', 'file', 'bar'))]) |
|
50 |
return builder |
|
51 |
||
3920.2.18
by Jelmer Vernooij
make sure dpush between native branches fails. |
52 |
def test_dpush_native(self): |
3920.2.30
by Jelmer Vernooij
Review from John. |
53 |
target_tree = self.make_branch_and_tree("dp") |
54 |
source_tree = self.make_branch_and_tree("dc") |
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
55 |
output, error = self.run_bzr("dpush -d dc dp", retcode=3) |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
56 |
self.assertEqual("", output) |
5777.6.3
by Jelmer Vernooij
Fix line formatting. |
57 |
self.assertContainsRe(error, |
58 |
'in the same VCS, lossy push not necessary. Please use regular '
|
|
59 |
'push.') |
|
3920.2.18
by Jelmer Vernooij
make sure dpush between native branches fails. |
60 |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
61 |
def test_dpush(self): |
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
62 |
branch = self.make_dummy_builder('d').get_branch() |
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
63 |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
64 |
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. |
65 |
self.build_tree(("dc/foo", "blaaaa")) |
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
66 |
dc.open_workingtree().commit('msg') |
67 |
||
5283.4.1
by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts |
68 |
script.run_script(self, """ |
69 |
$ bzr dpush -d dc d
|
|
5777.6.11
by Jelmer Vernooij
Fix revision id generation. |
70 |
2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
|
71 |
2>This may take some time. Upgrade the repositories to the same format for better performance.
|
|
5283.4.1
by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts |
72 |
2>Pushed up to revision 2.
|
73 |
$ bzr status dc
|
|
74 |
""") |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
75 |
|
76 |
def test_dpush_new(self): |
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
77 |
b = self.make_dummy_builder('d').get_branch() |
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
78 |
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
79 |
dc = b.bzrdir.sprout('dc', force_new_repo=True) |
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
80 |
self.build_tree_contents([("dc/foofile", "blaaaa")]) |
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
81 |
dc_tree = dc.open_workingtree() |
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
82 |
dc_tree.add("foofile") |
83 |
dc_tree.commit("msg") |
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
84 |
|
5283.4.1
by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts |
85 |
script.run_script(self, ''' |
86 |
$ bzr dpush -d dc d
|
|
5777.6.11
by Jelmer Vernooij
Fix revision id generation. |
87 |
2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
|
88 |
2>This may take some time. Upgrade the repositories to the same format for better performance.
|
|
5422.3.2
by Martin Pool
Update existing script tests to not ignore their output |
89 |
2>Pushed up to revision 2.
|
5283.4.1
by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts |
90 |
$ bzr revno dc
|
91 |
2
|
|
92 |
$ bzr status dc
|
|
93 |
''') |
|
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
94 |
|
95 |
def test_dpush_wt_diff(self): |
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
96 |
b = self.make_dummy_builder('d').get_branch() |
3920.2.10
by Jelmer Vernooij
More work trying to implement a dummy version control system. |
97 |
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
98 |
dc = b.bzrdir.sprout('dc', force_new_repo=True) |
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
99 |
self.build_tree_contents([("dc/foofile", "blaaaa")]) |
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
100 |
dc_tree = dc.open_workingtree() |
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
101 |
dc_tree.add("foofile") |
102 |
newrevid = dc_tree.commit('msg') |
|
3920.2.32
by Jelmer Vernooij
Avoid run_bzr for functions other than the one being tested. |
103 |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
104 |
self.build_tree_contents([("dc/foofile", "blaaaal")]) |
5283.4.1
by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts |
105 |
script.run_script(self, ''' |
106 |
$ bzr dpush -d dc d --no-strict
|
|
5777.6.11
by Jelmer Vernooij
Fix revision id generation. |
107 |
2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
|
108 |
2>This may take some time. Upgrade the repositories to the same format for better performance.
|
|
5422.3.2
by Martin Pool
Update existing script tests to not ignore their output |
109 |
2>Pushed up to revision 2.
|
5283.4.1
by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts |
110 |
''') |
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
111 |
self.assertFileEqual("blaaaal", "dc/foofile") |
4721.2.3
by Vincent Ladeuil
Make all test pass by implement --strict for dpush. |
112 |
# if the dummy vcs wasn't that dummy we could uncomment the line below
|
113 |
# self.assertFileEqual("blaaaa", "d/foofile")
|
|
5283.4.1
by Martin Pool
Deprecate ExternalBase.check_output and update some callers to use scripts |
114 |
script.run_script(self, ''' |
115 |
$ bzr status dc
|
|
116 |
modified:
|
|
117 |
foofile
|
|
118 |
''') |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
119 |
|
120 |
def test_diverged(self): |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
121 |
builder = self.make_dummy_builder('d') |
122 |
||
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
123 |
b = builder.get_branch() |
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
124 |
|
4721.2.1
by Vincent Ladeuil
Some test cleamup. |
125 |
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. |
126 |
dc_tree = dc.open_workingtree() |
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
127 |
|
128 |
self.build_tree_contents([("dc/foo", "bar")]) |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
129 |
dc_tree.commit('msg1') |
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
130 |
|
3920.2.33
by Jelmer Vernooij
Use branch_builder to create revisions in testsuite. |
131 |
builder.build_snapshot('revid2', None, |
132 |
[('modify', ('fooid', 'blie'))]) |
|
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
133 |
|
3920.2.36
by Jelmer Vernooij
Fix tests after CommitBuilder changes. |
134 |
output, error = self.run_bzr("dpush -d dc d", retcode=3) |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
135 |
self.assertEqual(output, "") |
3920.2.20
by Jelmer Vernooij
Fix dpush tests. |
136 |
self.assertContainsRe(error, "have diverged") |
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
137 |
|
138 |
||
139 |
class TestDpushStrictMixin(object): |
|
140 |
||
4721.2.7
by Vincent Ladeuil
Final tweak. |
141 |
def setUp(self): |
142 |
test_foreign.register_dummy_foreign_for_test(self) |
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
143 |
# Create an empty branch where we will be able to push
|
144 |
self.foreign = self.make_branch( |
|
4721.2.7
by Vincent Ladeuil
Final tweak. |
145 |
'to', format=test_foreign.DummyForeignVcsDirFormat()) |
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
146 |
|
4721.2.6
by Vincent Ladeuil
More agressive test sharing between push and dpush. |
147 |
def set_config_push_strict(self, value): |
6404.6.1
by Vincent Ladeuil
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. |
148 |
br = branch.Branch.open('local') |
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
149 |
br.get_config_stack().set('dpush_strict', value) |
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
150 |
|
151 |
_default_command = ['dpush', '../to'] |
|
152 |
||
153 |
||
4721.2.6
by Vincent Ladeuil
More agressive test sharing between push and dpush. |
154 |
class TestDpushStrictWithoutChanges(TestDpushStrictMixin, |
155 |
test_push.TestPushStrictWithoutChanges): |
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
156 |
|
157 |
def setUp(self): |
|
4721.2.7
by Vincent Ladeuil
Final tweak. |
158 |
test_push.TestPushStrictWithoutChanges.setUp(self) |
159 |
TestDpushStrictMixin.setUp(self) |
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
160 |
|
4721.2.6
by Vincent Ladeuil
More agressive test sharing between push and dpush. |
161 |
|
162 |
class TestDpushStrictWithChanges(TestDpushStrictMixin, |
|
163 |
test_push.TestPushStrictWithChanges): |
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
164 |
|
5559.2.2
by Martin Pool
Change to using standard load_tests_apply_scenarios. |
165 |
scenarios = test_push.strict_push_change_scenarios |
166 |
||
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
167 |
_changes_type = None # Set by load_tests |
168 |
||
169 |
def setUp(self): |
|
4721.2.7
by Vincent Ladeuil
Final tweak. |
170 |
test_push.TestPushStrictWithChanges.setUp(self) |
171 |
TestDpushStrictMixin.setUp(self) |
|
4721.2.2
by Vincent Ladeuil
Start testing and implementing --strict for dpush. |
172 |
|
4721.2.6
by Vincent Ladeuil
More agressive test sharing between push and dpush. |
173 |
def test_push_with_revision(self): |
174 |
raise tests.TestNotApplicable('dpush does not handle --revision') |