bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
1 |
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
|
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
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
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
16 |
#
|
17 |
||
18 |
"""Tests of the 'bzr add' command."""
|
|
19 |
||
20 |
import os |
|
21 |
||
|
4163.2.2
by Ian Clatworthy
use multiply_tests rather than subclassing |
22 |
from bzrlib.tests import ( |
23 |
condition_isinstance, |
|
24 |
split_suite_by_condition, |
|
25 |
multiply_tests, |
|
26 |
)
|
|
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
27 |
from bzrlib.tests.blackbox import ExternalBase |
|
2617.5.8
by Kuno Meyer
Extended tests for unicode chars outside of the iso-8859-* range |
28 |
from bzrlib.tests.test_win32utils import NeedsGlobExpansionFeature |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
29 |
|
30 |
||
|
4163.2.2
by Ian Clatworthy
use multiply_tests rather than subclassing |
31 |
def load_tests(standard_tests, module, loader): |
32 |
"""Parameterize tests for view-aware vs not.""" |
|
33 |
to_adapt, result = split_suite_by_condition( |
|
34 |
standard_tests, condition_isinstance(TestAdd)) |
|
35 |
scenarios = [ |
|
36 |
('pre-views', {'branch_tree_format': 'pack-0.92'}), |
|
|
4210.4.2
by Ian Clatworthy
split filtered views support out into WorkingTreeFormat6 |
37 |
('view-aware', {'branch_tree_format': 'development-wt6'}), |
|
4163.2.2
by Ian Clatworthy
use multiply_tests rather than subclassing |
38 |
]
|
39 |
return multiply_tests(to_adapt, scenarios, result) |
|
40 |
||
41 |
||
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
42 |
class TestAdd(ExternalBase): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
43 |
|
|
4163.2.1
by Ian Clatworthy
Fix add in trees supports views |
44 |
def make_branch_and_tree(self, dir): |
45 |
return ExternalBase.make_branch_and_tree(self, dir, |
|
46 |
format=self.branch_tree_format) |
|
47 |
||
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
48 |
def test_add_reports(self): |
49 |
"""add command prints the names of added files.""" |
|
|
2664.3.1
by Daniel Watkins
tests.blackbox.test_add now uses internals where appropriate. |
50 |
tree = self.make_branch_and_tree('.') |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
51 |
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt', 'CVS']) |
|
1765.1.1
by Robert Collins
Remove the default ignores list from bzr, lowering the minimum overhead in bzr add. |
52 |
self.build_tree_contents([('.bzrignore', 'CVS\n')]) |
|
2581.1.2
by Martin Pool
Remove unnecessary retcode=0 to run_bzr calls |
53 |
out = self.run_bzr('add')[0] |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
54 |
# the ordering is not defined at the moment
|
55 |
results = sorted(out.rstrip('\n').split('\n')) |
|
56 |
self.assertEquals(['If you wish to add some of these files, please'\ |
|
57 |
' add them by name.', |
|
|
3985.2.1
by Daniel Watkins
Updated tests for new behaviour. |
58 |
'adding .bzrignore', |
59 |
'adding dir', |
|
60 |
'adding dir/sub.txt', |
|
61 |
'adding top.txt', |
|
|
1987.1.1
by John Arbash Meinel
Update the test suite to put HOME in a different directory |
62 |
'ignored 1 file(s).'], |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
63 |
results) |
|
2581.1.2
by Martin Pool
Remove unnecessary retcode=0 to run_bzr calls |
64 |
out = self.run_bzr('add -v')[0] |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
65 |
results = sorted(out.rstrip('\n').split('\n')) |
66 |
self.assertEquals(['If you wish to add some of these files, please'\ |
|
67 |
' add them by name.', |
|
68 |
'ignored CVS matching "CVS"'], |
|
69 |
results) |
|
70 |
||
71 |
def test_add_quiet_is(self): |
|
72 |
"""add -q does not print the names of added files.""" |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
73 |
tree = self.make_branch_and_tree('.') |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
74 |
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt']) |
|
2581.1.2
by Martin Pool
Remove unnecessary retcode=0 to run_bzr calls |
75 |
out = self.run_bzr('add -q')[0] |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
76 |
# the ordering is not defined at the moment
|
77 |
results = sorted(out.rstrip('\n').split('\n')) |
|
78 |
self.assertEquals([''], results) |
|
79 |
||
80 |
def test_add_in_unversioned(self): |
|
81 |
"""Try to add a file in an unversioned directory. |
|
82 |
||
83 |
"bzr add" should add the parent(s) as necessary.
|
|
84 |
"""
|
|
|
2664.3.1
by Daniel Watkins
tests.blackbox.test_add now uses internals where appropriate. |
85 |
tree = self.make_branch_and_tree('.') |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
86 |
self.build_tree(['inertiatic/', 'inertiatic/esp']) |
|
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
87 |
self.assertEquals(self.run_bzr('unknowns')[0], 'inertiatic\n') |
|
2530.3.3
by Martin Pool
Clean up some callers that use varargs syntax for run_bzr, but don't |
88 |
self.run_bzr('add inertiatic/esp') |
|
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
89 |
self.assertEquals(self.run_bzr('unknowns')[0], '') |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
90 |
|
91 |
# Multiple unversioned parents
|
|
92 |
self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt']) |
|
|
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
93 |
self.assertEquals(self.run_bzr('unknowns')[0], 'veil\n') |
|
2530.3.3
by Martin Pool
Clean up some callers that use varargs syntax for run_bzr, but don't |
94 |
self.run_bzr('add veil/cerpin/taxt') |
|
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
95 |
self.assertEquals(self.run_bzr('unknowns')[0], '') |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
96 |
|
97 |
# Check whacky paths work
|
|
98 |
self.build_tree(['cicatriz/', 'cicatriz/esp']) |
|
|
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
99 |
self.assertEquals(self.run_bzr('unknowns')[0], 'cicatriz\n') |
|
2530.3.3
by Martin Pool
Clean up some callers that use varargs syntax for run_bzr, but don't |
100 |
self.run_bzr('add inertiatic/../cicatriz/esp') |
|
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
101 |
self.assertEquals(self.run_bzr('unknowns')[0], '') |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
102 |
|
103 |
def test_add_in_versioned(self): |
|
104 |
"""Try to add a file in a versioned directory. |
|
105 |
||
106 |
"bzr add" should do this happily.
|
|
107 |
"""
|
|
|
2664.3.1
by Daniel Watkins
tests.blackbox.test_add now uses internals where appropriate. |
108 |
tree = self.make_branch_and_tree('.') |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
109 |
self.build_tree(['inertiatic/', 'inertiatic/esp']) |
|
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
110 |
self.assertEquals(self.run_bzr('unknowns')[0], 'inertiatic\n') |
|
2530.3.3
by Martin Pool
Clean up some callers that use varargs syntax for run_bzr, but don't |
111 |
self.run_bzr('add --no-recurse inertiatic') |
|
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
112 |
self.assertEquals(self.run_bzr('unknowns')[0], 'inertiatic/esp\n') |
|
2530.3.3
by Martin Pool
Clean up some callers that use varargs syntax for run_bzr, but don't |
113 |
self.run_bzr('add inertiatic/esp') |
|
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
114 |
self.assertEquals(self.run_bzr('unknowns')[0], '') |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
115 |
|
116 |
def test_subdir_add(self): |
|
117 |
"""Add in subdirectory should add only things from there down""" |
|
118 |
from bzrlib.workingtree import WorkingTree |
|
|
1836.1.16
by John Arbash Meinel
Cleanup some tests which don't expect .bazaar/ to show up. Some still fail. |
119 |
|
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
120 |
eq = self.assertEqual |
|
1836.1.16
by John Arbash Meinel
Cleanup some tests which don't expect .bazaar/ to show up. Some still fail. |
121 |
ass = self.assertTrue |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
122 |
chdir = os.chdir |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
123 |
|
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
124 |
t = self.make_branch_and_tree('.') |
125 |
b = t.branch |
|
126 |
self.build_tree(['src/', 'README']) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
127 |
|
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
128 |
eq(sorted(t.unknowns()), |
129 |
['README', 'src']) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
130 |
|
|
2530.3.3
by Martin Pool
Clean up some callers that use varargs syntax for run_bzr, but don't |
131 |
self.run_bzr('add src') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
132 |
|
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
133 |
self.build_tree(['src/foo.c']) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
134 |
|
|
2255.2.171
by Martin Pool
Fix up blackbox test_add to avoid depending on inventory not being held in memory |
135 |
# add with no arguments in a subdirectory gets only files below that
|
136 |
# subdirectory
|
|
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
137 |
chdir('src') |
138 |
self.run_bzr('add') |
|
|
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
139 |
self.assertEquals(self.run_bzr('unknowns')[0], 'README\n') |
|
2255.2.176
by Martin Pool
Merge dirstate and some small cleanups |
140 |
# reopen to see the new changes
|
141 |
t = t.bzrdir.open_workingtree() |
|
|
2255.2.171
by Martin Pool
Fix up blackbox test_add to avoid depending on inventory not being held in memory |
142 |
versioned = [path for path, entry in t.iter_entries_by_dir()] |
143 |
self.assertEquals(versioned, |
|
144 |
['', 'src', 'src/foo.c']) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
145 |
|
|
2255.2.171
by Martin Pool
Fix up blackbox test_add to avoid depending on inventory not being held in memory |
146 |
# add from the parent directory should pick up all file names
|
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
147 |
chdir('..') |
148 |
self.run_bzr('add') |
|
|
2552.2.2
by Vincent Ladeuil
Enforce run_bzr(string) where possible. |
149 |
self.assertEquals(self.run_bzr('unknowns')[0], '') |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
150 |
self.run_bzr('check') |
|
1757.2.1
by Robert Collins
Add an explicit test that adding a missing file barfs. |
151 |
|
152 |
def test_add_missing(self): |
|
153 |
"""bzr add foo where foo is missing should error.""" |
|
154 |
self.make_branch_and_tree('.') |
|
|
2530.3.3
by Martin Pool
Clean up some callers that use varargs syntax for run_bzr, but don't |
155 |
self.run_bzr('add missing-file', retcode=3) |
|
1911.3.2
by John Arbash Meinel
Adding the AddFromBaseAction, which tries to reuse file ids from another tree |
156 |
|
157 |
def test_add_from(self): |
|
158 |
base_tree = self.make_branch_and_tree('base') |
|
159 |
self.build_tree(['base/a', 'base/b/', 'base/b/c']) |
|
160 |
base_tree.add(['a', 'b', 'b/c']) |
|
161 |
base_tree.commit('foo') |
|
162 |
||
163 |
new_tree = self.make_branch_and_tree('new') |
|
164 |
self.build_tree(['new/a', 'new/b/', 'new/b/c', 'd']) |
|
165 |
||
166 |
os.chdir('new') |
|
|
2530.3.3
by Martin Pool
Clean up some callers that use varargs syntax for run_bzr, but don't |
167 |
out, err = self.run_bzr('add --file-ids-from ../base') |
|
1911.3.2
by John Arbash Meinel
Adding the AddFromBaseAction, which tries to reuse file ids from another tree |
168 |
self.assertEqual('', err) |
|
3985.2.1
by Daniel Watkins
Updated tests for new behaviour. |
169 |
self.assertEqualDiff('adding a w/ file id from a\n' |
170 |
'adding b w/ file id from b\n' |
|
|
4075.1.1
by Robert Collins
add should not print 'add completed' unnecessarily. |
171 |
'adding b/c w/ file id from b/c\n', |
|
1911.3.2
by John Arbash Meinel
Adding the AddFromBaseAction, which tries to reuse file ids from another tree |
172 |
out) |
|
2255.2.171
by Martin Pool
Fix up blackbox test_add to avoid depending on inventory not being held in memory |
173 |
new_tree = new_tree.bzrdir.open_workingtree() |
|
1911.3.2
by John Arbash Meinel
Adding the AddFromBaseAction, which tries to reuse file ids from another tree |
174 |
self.assertEqual(base_tree.path2id('a'), new_tree.path2id('a')) |
175 |
self.assertEqual(base_tree.path2id('b'), new_tree.path2id('b')) |
|
176 |
self.assertEqual(base_tree.path2id('b/c'), new_tree.path2id('b/c')) |
|
177 |
||
178 |
def test_add_from_subdir(self): |
|
179 |
base_tree = self.make_branch_and_tree('base') |
|
180 |
self.build_tree(['base/a', 'base/b/', 'base/b/c', 'base/b/d']) |
|
181 |
base_tree.add(['a', 'b', 'b/c', 'b/d']) |
|
182 |
base_tree.commit('foo') |
|
183 |
||
184 |
new_tree = self.make_branch_and_tree('new') |
|
185 |
self.build_tree(['new/c', 'new/d']) |
|
186 |
||
187 |
os.chdir('new') |
|
|
2530.3.3
by Martin Pool
Clean up some callers that use varargs syntax for run_bzr, but don't |
188 |
out, err = self.run_bzr('add --file-ids-from ../base/b') |
|
1911.3.2
by John Arbash Meinel
Adding the AddFromBaseAction, which tries to reuse file ids from another tree |
189 |
self.assertEqual('', err) |
|
3985.2.1
by Daniel Watkins
Updated tests for new behaviour. |
190 |
self.assertEqualDiff('adding c w/ file id from b/c\n' |
|
4075.1.1
by Robert Collins
add should not print 'add completed' unnecessarily. |
191 |
'adding d w/ file id from b/d\n', |
|
1911.3.2
by John Arbash Meinel
Adding the AddFromBaseAction, which tries to reuse file ids from another tree |
192 |
out) |
193 |
||
|
2255.2.171
by Martin Pool
Fix up blackbox test_add to avoid depending on inventory not being held in memory |
194 |
new_tree = new_tree.bzrdir.open_workingtree() |
|
1911.3.2
by John Arbash Meinel
Adding the AddFromBaseAction, which tries to reuse file ids from another tree |
195 |
self.assertEqual(base_tree.path2id('b/c'), new_tree.path2id('c')) |
196 |
self.assertEqual(base_tree.path2id('b/d'), new_tree.path2id('d')) |
|
|
1928.1.1
by Alexander Belchenko
blackbox test for 'bzr add --dry-run' |
197 |
|
198 |
def test_add_dry_run(self): |
|
|
2568.2.4
by Robert Collins
* ``bzrlib.add.smart_add`` and ``bzrlib.add.smart_add_tree`` are now |
199 |
"""Test a dry run add, make sure nothing is added.""" |
200 |
wt = self.make_branch_and_tree('.') |
|
201 |
self.build_tree(['inertiatic/', 'inertiatic/esp']) |
|
202 |
self.assertEqual(list(wt.unknowns()), ['inertiatic']) |
|
203 |
self.run_bzr('add --dry-run') |
|
204 |
self.assertEqual(list(wt.unknowns()), ['inertiatic']) |
|
|
2279.5.1
by Matthias Rahlf
FastPath objects can now be printed nicely |
205 |
|
206 |
def test_add_control_dir(self): |
|
207 |
"""The control dir and its content should be refused.""" |
|
|
2279.6.1
by Alexander Belchenko
Instead of __str__ method for FastPath object we use .raw_path attribute (note from Aaron). |
208 |
self.make_branch_and_tree('.') |
|
2530.3.3
by Martin Pool
Clean up some callers that use varargs syntax for run_bzr, but don't |
209 |
err = self.run_bzr('add .bzr', retcode=3)[1] |
|
2279.5.1
by Matthias Rahlf
FastPath objects can now be printed nicely |
210 |
self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file') |
|
2530.3.3
by Martin Pool
Clean up some callers that use varargs syntax for run_bzr, but don't |
211 |
err = self.run_bzr('add .bzr/README', retcode=3)[1] |
|
2279.5.1
by Matthias Rahlf
FastPath objects can now be printed nicely |
212 |
self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file') |
213 |
self.build_tree(['.bzr/crescent']) |
|
|
2530.3.3
by Martin Pool
Clean up some callers that use varargs syntax for run_bzr, but don't |
214 |
err = self.run_bzr('add .bzr/crescent', retcode=3)[1] |
|
2279.5.1
by Matthias Rahlf
FastPath objects can now be printed nicely |
215 |
self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file') |
|
2617.5.3
by Kuno Meyer
Blackbox test for adding with wildcards (Win32). |
216 |
|
217 |
def test_add_with_wildcards(self): |
|
|
2617.5.8
by Kuno Meyer
Extended tests for unicode chars outside of the iso-8859-* range |
218 |
self.requireFeature(NeedsGlobExpansionFeature) |
|
2617.5.4
by Kuno Meyer
Included feedback on initial patch. |
219 |
self.make_branch_and_tree('.') |
|
2617.5.3
by Kuno Meyer
Blackbox test for adding with wildcards (Win32). |
220 |
self.build_tree(['a1', 'a2', 'b', 'c33']) |
|
2617.5.4
by Kuno Meyer
Included feedback on initial patch. |
221 |
self.run_bzr(['add', 'a?', 'c*']) |
|
2617.5.3
by Kuno Meyer
Blackbox test for adding with wildcards (Win32). |
222 |
self.assertEquals(self.run_bzr('unknowns')[0], 'b\n') |
|
2617.5.8
by Kuno Meyer
Extended tests for unicode chars outside of the iso-8859-* range |
223 |
|
224 |
def test_add_with_wildcards_unicode(self): |
|
225 |
self.requireFeature(NeedsGlobExpansionFeature) |
|
226 |
self.make_branch_and_tree('.') |
|
227 |
self.build_tree([u'\u1234A', u'\u1235A', u'\u1235AA', 'cc']) |
|
228 |
self.run_bzr(['add', u'\u1234?', u'\u1235*']) |
|
229 |
self.assertEquals(self.run_bzr('unknowns')[0], 'cc\n') |