bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
5273.1.8
by Vincent Ladeuil
Merge bzr.dev into cleanup |
1 |
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
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
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
16 |
#
|
17 |
||
18 |
"""Tests variations of case-insensitive and case-preserving file-systems."""
|
|
19 |
||
20 |
import os |
|
21 |
||
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
22 |
from ... import ( |
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
23 |
osutils, |
24 |
tests, |
|
|
5186.2.2
by Martin Pool
wrap os.rename to insert the source and destination filenames in any exception that may be raised |
25 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
26 |
from .. import KnownFailure |
27 |
from ...osutils import canonical_relpath, pathjoin |
|
28 |
from ..script import run_script |
|
29 |
from ..features import ( |
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
30 |
CaseInsCasePresFilenameFeature, |
31 |
)
|
|
32 |
||
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
33 |
|
34 |
class TestCICPBase(tests.TestCaseWithTransport): |
|
|
3794.5.23
by Mark Hammond
reoganize tests into categories. |
35 |
"""Base class for tests on a case-insensitive, case-preserving filesystem. |
|
3794.5.9
by Mark Hammond
Correct line-endings. |
36 |
"""
|
37 |
||
38 |
_test_needs_features = [CaseInsCasePresFilenameFeature] |
|
39 |
||
40 |
def _make_mixed_case_tree(self): |
|
41 |
"""Make a working tree with mixed-case filenames.""" |
|
42 |
wt = self.make_branch_and_tree('.') |
|
43 |
# create a file on disk with the mixed-case parent and base name
|
|
44 |
self.build_tree(['CamelCaseParent/', 'lowercaseparent/']) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
45 |
self.build_tree_contents([('CamelCaseParent/CamelCase', b'camel case'), |
46 |
('lowercaseparent/lowercase', b'lower case'), |
|
47 |
('lowercaseparent/mixedCase', b'mixedCasecase'), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
48 |
])
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
49 |
return wt |
50 |
||
|
3794.5.31
by Mark Hammond
bulk of the simple review comments from igc. |
51 |
|
|
3794.5.23
by Mark Hammond
reoganize tests into categories. |
52 |
class TestAdd(TestCICPBase): |
|
4241.9.2
by Vincent Ladeuil
Fix most of cicp related failures on OSX. |
53 |
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
54 |
def test_add_simple(self): |
55 |
"""Test add always uses the case of the filename reported by the os.""" |
|
56 |
wt = self.make_branch_and_tree('.') |
|
57 |
# create a file on disk with the mixed-case name
|
|
58 |
self.build_tree(['CamelCase']) |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
59 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
60 |
$ brz add camelcase
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
61 |
adding CamelCase
|
62 |
""") |
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
63 |
|
64 |
def test_add_subdir(self): |
|
65 |
"""test_add_simple but with subdirectories tested too.""" |
|
66 |
wt = self.make_branch_and_tree('.') |
|
67 |
# create a file on disk with the mixed-case parent and base name
|
|
68 |
self.build_tree(['CamelCaseParent/', 'CamelCaseParent/CamelCase']) |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
69 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
70 |
$ brz add camelcaseparent/camelcase
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
71 |
adding CamelCaseParent
|
72 |
adding CamelCaseParent/CamelCase
|
|
73 |
""") |
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
74 |
|
75 |
def test_add_implied(self): |
|
76 |
"""test add with no args sees the correct names.""" |
|
77 |
wt = self.make_branch_and_tree('.') |
|
78 |
# create a file on disk with the mixed-case parent and base name
|
|
79 |
self.build_tree(['CamelCaseParent/', 'CamelCaseParent/CamelCase']) |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
80 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
81 |
$ brz add
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
82 |
adding CamelCaseParent
|
83 |
adding CamelCaseParent/CamelCase
|
|
84 |
""") |
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
85 |
|
|
3794.5.23
by Mark Hammond
reoganize tests into categories. |
86 |
def test_re_add(self): |
87 |
"""Test than when a file has 'unintentionally' changed case, we can't |
|
88 |
add a new entry using the new case."""
|
|
89 |
wt = self.make_branch_and_tree('.') |
|
90 |
# create a file on disk with the mixed-case name
|
|
91 |
self.build_tree(['MixedCase']) |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
92 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
93 |
$ brz add MixedCase
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
94 |
adding MixedCase
|
95 |
""") |
|
|
3794.5.23
by Mark Hammond
reoganize tests into categories. |
96 |
# 'accidently' rename the file on disk
|
|
5186.2.2
by Martin Pool
wrap os.rename to insert the source and destination filenames in any exception that may be raised |
97 |
osutils.rename('MixedCase', 'mixedcase') |
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
98 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
99 |
$ brz add mixedcase
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
100 |
""") |
|
3794.5.23
by Mark Hammond
reoganize tests into categories. |
101 |
|
102 |
def test_re_add_dir(self): |
|
103 |
# like re-add, but tests when the operation is on a directory.
|
|
104 |
"""Test than when a file has 'unintentionally' changed case, we can't |
|
105 |
add a new entry using the new case."""
|
|
106 |
wt = self.make_branch_and_tree('.') |
|
107 |
# create a file on disk with the mixed-case name
|
|
108 |
self.build_tree(['MixedCaseParent/', 'MixedCaseParent/MixedCase']) |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
109 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
110 |
$ brz add MixedCaseParent
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
111 |
adding MixedCaseParent
|
112 |
adding MixedCaseParent/MixedCase
|
|
113 |
""") |
|
|
3794.5.23
by Mark Hammond
reoganize tests into categories. |
114 |
# 'accidently' rename the directory on disk
|
|
5186.2.2
by Martin Pool
wrap os.rename to insert the source and destination filenames in any exception that may be raised |
115 |
osutils.rename('MixedCaseParent', 'mixedcaseparent') |
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
116 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
117 |
$ brz add mixedcaseparent
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
118 |
""") |
|
3794.5.23
by Mark Hammond
reoganize tests into categories. |
119 |
|
|
3794.5.36
by Mark Hammond
test for, and fix problem with canonical_relpath when the tail does not exist. |
120 |
def test_add_not_found(self): |
121 |
"""Test add when the input file doesn't exist.""" |
|
122 |
wt = self.make_branch_and_tree('.') |
|
123 |
# create a file on disk with the mixed-case name
|
|
124 |
self.build_tree(['MixedCaseParent/', 'MixedCaseParent/MixedCase']) |
|
125 |
expected_fname = pathjoin(wt.basedir, "MixedCaseParent", "notfound") |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
126 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
127 |
$ brz add mixedcaseparent/notfound
|
128 |
2>brz: ERROR: No such file: %s |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
129 |
""" % (repr(expected_fname),)) |
|
3794.5.36
by Mark Hammond
test for, and fix problem with canonical_relpath when the tail does not exist. |
130 |
|
|
3794.5.23
by Mark Hammond
reoganize tests into categories. |
131 |
|
132 |
class TestMove(TestCICPBase): |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
133 |
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
134 |
def test_mv_newname(self): |
135 |
wt = self._make_mixed_case_tree() |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
136 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
137 |
$ brz add -q
|
138 |
$ brz ci -qm message
|
|
139 |
$ brz mv camelcaseparent/camelcase camelcaseparent/NewCamelCase
|
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
140 |
CamelCaseParent/CamelCase => CamelCaseParent/NewCamelCase
|
141 |
""") |
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
142 |
|
143 |
def test_mv_newname_after(self): |
|
144 |
wt = self._make_mixed_case_tree() |
|
145 |
# In this case we can specify the incorrect case for the destination,
|
|
146 |
# as we use --after, so the file-system is sniffed.
|
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
147 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
148 |
$ brz add -q
|
149 |
$ brz ci -qm message
|
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
150 |
$ mv CamelCaseParent/CamelCase CamelCaseParent/NewCamelCase
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
151 |
$ brz mv --after camelcaseparent/camelcase camelcaseparent/newcamelcase
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
152 |
CamelCaseParent/CamelCase => CamelCaseParent/NewCamelCase
|
153 |
""") |
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
154 |
|
|
3794.5.21
by Mark Hammond
More cicp-filesystem tests |
155 |
def test_mv_newname_exists(self): |
156 |
# test a mv, but when the target already exists with a name that
|
|
157 |
# differs only by case.
|
|
158 |
wt = self._make_mixed_case_tree() |
|
159 |
self.run_bzr('add') |
|
160 |
self.run_bzr('ci -m message') |
|
|
5283.4.3
by Martin Pool
Remove old check_error_output helper |
161 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
162 |
$ brz mv camelcaseparent/camelcase LOWERCASEPARENT/LOWERCASE
|
163 |
2>brz: ERROR: Could not move CamelCase => lowercase: \ |
|
|
5283.4.3
by Martin Pool
Remove old check_error_output helper |
164 |
lowercaseparent/lowercase is already versioned.
|
165 |
""") |
|
|
3794.5.21
by Mark Hammond
More cicp-filesystem tests |
166 |
|
167 |
def test_mv_newname_exists_after(self): |
|
168 |
# test a 'mv --after', but when the target already exists with a name
|
|
169 |
# that differs only by case. Note that this is somewhat unlikely
|
|
170 |
# but still reasonable.
|
|
171 |
wt = self._make_mixed_case_tree() |
|
172 |
self.run_bzr('add') |
|
173 |
self.run_bzr('ci -m message') |
|
174 |
# Remove the source and create a destination file on disk with a different case.
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
175 |
# brz should report that the filename is already versioned.
|
|
3794.5.21
by Mark Hammond
More cicp-filesystem tests |
176 |
os.unlink('CamelCaseParent/CamelCase') |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
177 |
osutils.rename('lowercaseparent/lowercase', |
178 |
'lowercaseparent/LOWERCASE') |
|
|
5283.4.3
by Martin Pool
Remove old check_error_output helper |
179 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
180 |
$ brz mv --after camelcaseparent/camelcase LOWERCASEPARENT/LOWERCASE
|
181 |
2>brz: ERROR: Could not move CamelCase => lowercase: \ |
|
|
5283.4.3
by Martin Pool
Remove old check_error_output helper |
182 |
lowercaseparent/lowercase is already versioned.
|
183 |
""") |
|
|
3794.5.21
by Mark Hammond
More cicp-filesystem tests |
184 |
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
185 |
def test_mv_newname_root(self): |
186 |
wt = self._make_mixed_case_tree() |
|
187 |
self.run_bzr('add') |
|
188 |
self.run_bzr('ci -m message') |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
189 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
190 |
$ brz mv camelcaseparent NewCamelCaseParent
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
191 |
CamelCaseParent => NewCamelCaseParent
|
192 |
""") |
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
193 |
|
194 |
def test_mv_newname_root_after(self): |
|
195 |
wt = self._make_mixed_case_tree() |
|
196 |
self.run_bzr('add') |
|
197 |
self.run_bzr('ci -m message') |
|
198 |
# In this case we can specify the incorrect case for the destination,
|
|
199 |
# as we use --after, so the file-system is sniffed.
|
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
200 |
run_script(self, """ |
201 |
$ mv CamelCaseParent NewCamelCaseParent
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
202 |
$ brz mv --after camelcaseparent NewCamelCaseParent
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
203 |
CamelCaseParent => NewCamelCaseParent
|
204 |
""") |
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
205 |
|
206 |
def test_mv_newcase(self): |
|
207 |
wt = self._make_mixed_case_tree() |
|
208 |
self.run_bzr('add') |
|
209 |
self.run_bzr('ci -m message') |
|
210 |
||
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
211 |
# perform a mv to the new case - we expect brz to accept the new
|
|
3794.5.21
by Mark Hammond
More cicp-filesystem tests |
212 |
# name, as specified, and rename the file on the file-system too.
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
213 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
214 |
$ brz mv camelcaseparent/camelcase camelcaseparent/camelCase
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
215 |
CamelCaseParent/CamelCase => CamelCaseParent/camelCase
|
216 |
""") |
|
|
6619.3.13
by Jelmer Vernooij
Run 2to3 asserts fixers. |
217 |
self.assertEqual(canonical_relpath(wt.basedir, 'camelcaseparent/camelcase'), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
218 |
'CamelCaseParent/camelCase') |
|
3794.5.21
by Mark Hammond
More cicp-filesystem tests |
219 |
|
220 |
def test_mv_newcase_after(self): |
|
221 |
wt = self._make_mixed_case_tree() |
|
222 |
self.run_bzr('add') |
|
223 |
self.run_bzr('ci -m message') |
|
224 |
||
|
3794.5.9
by Mark Hammond
Correct line-endings. |
225 |
# perform a mv to the new case - we must ensure the file-system has the
|
226 |
# new case first.
|
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
227 |
osutils.rename('CamelCaseParent/CamelCase', |
228 |
'CamelCaseParent/camelCase') |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
229 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
230 |
$ brz mv --after camelcaseparent/camelcase camelcaseparent/camelCase
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
231 |
CamelCaseParent/CamelCase => CamelCaseParent/camelCase
|
232 |
""") |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
233 |
# brz should not have renamed the file to a different case
|
|
6619.3.13
by Jelmer Vernooij
Run 2to3 asserts fixers. |
234 |
self.assertEqual(canonical_relpath(wt.basedir, 'camelcaseparent/camelcase'), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
235 |
'CamelCaseParent/camelCase') |
|
3794.5.9
by Mark Hammond
Correct line-endings. |
236 |
|
237 |
def test_mv_multiple(self): |
|
238 |
wt = self._make_mixed_case_tree() |
|
239 |
self.run_bzr('add') |
|
240 |
self.run_bzr('ci -m message') |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
241 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
242 |
$ brz mv LOWercaseparent/LOWercase LOWercaseparent/MIXEDCase camelcaseparent
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
243 |
lowercaseparent/lowercase => CamelCaseParent/lowercase
|
244 |
lowercaseparent/mixedCase => CamelCaseParent/mixedCase
|
|
245 |
""") |
|
|
3794.5.9
by Mark Hammond
Correct line-endings. |
246 |
|
|
3794.5.23
by Mark Hammond
reoganize tests into categories. |
247 |
|
248 |
class TestMisc(TestCICPBase): |
|
|
4651.2.1
by Vincent Ladeuil
Catch up fix for #347649. |
249 |
|
|
3794.5.23
by Mark Hammond
reoganize tests into categories. |
250 |
def test_status(self): |
251 |
wt = self._make_mixed_case_tree() |
|
252 |
self.run_bzr('add') |
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
253 |
run_script(self, """ |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
254 |
$ brz status camelcaseparent/camelcase LOWERCASEPARENT/LOWERCASE
|
|
5283.4.2
by Martin Pool
Change test_filesystem_cicp to use scripts rather than ExternalBase |
255 |
added:
|
256 |
CamelCaseParent/
|
|
257 |
CamelCaseParent/CamelCase
|
|
258 |
lowercaseparent/
|
|
259 |
lowercaseparent/lowercase
|
|
260 |
""") |
|
|
3794.5.23
by Mark Hammond
reoganize tests into categories. |
261 |
|
262 |
def test_ci(self): |
|
263 |
wt = self._make_mixed_case_tree() |
|
264 |
self.run_bzr('add') |
|
265 |
||
266 |
got = self.run_bzr('ci -m message camelcaseparent LOWERCASEPARENT')[1] |
|
267 |
for expected in ['CamelCaseParent', 'lowercaseparent', |
|
268 |
'CamelCaseParent/CamelCase', 'lowercaseparent/lowercase']: |
|
269 |
self.assertContainsRe(got, 'added ' + expected + '\n') |
|
270 |
||
271 |
def test_rm(self): |
|
272 |
wt = self._make_mixed_case_tree() |
|
273 |
self.run_bzr('add') |
|
274 |
self.run_bzr('ci -m message') |
|
275 |
||
276 |
got = self.run_bzr('rm camelcaseparent LOWERCASEPARENT')[1] |
|
277 |
for expected in ['lowercaseparent/lowercase', 'CamelCaseParent/CamelCase']: |
|
278 |
self.assertContainsRe(got, 'deleted ' + expected + '\n') |
|
279 |
||
|
3794.5.10
by Mark Hammond
Add comments about commands that should still get love. |
280 |
# The following commands need tests and/or cicp lovin':
|
281 |
# update, remove, file_id, file_path, diff, log, touching_revisions, ls,
|
|
|
3794.5.31
by Mark Hammond
bulk of the simple review comments from igc. |
282 |
# ignore, cat, revert, resolve.
|