bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2006-2010, 2016 Canonical Ltd
|
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
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
|
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
16 |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
17 |
"""UI tests for brz ignore."""
|
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
18 |
|
19 |
||
20 |
import os |
|
21 |
import re |
|
22 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
23 |
from breezy import ( |
|
1996.3.18
by John Arbash Meinel
Now that mkdtemp and rmtree are lazy, they should not be directly improted. |
24 |
ignores, |
25 |
osutils, |
|
26 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
27 |
import breezy |
28 |
from breezy.branch import Branch |
|
|
6670.4.3
by Jelmer Vernooij
Fix more imports. |
29 |
import breezy.bzr.bzrdir as bzrdir |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
30 |
from breezy.errors import BzrCommandError |
31 |
from breezy.osutils import ( |
|
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
32 |
pathjoin, |
33 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
34 |
from breezy.tests.test_sftp_transport import TestCaseWithSFTPServer |
35 |
from breezy.tests import TestCaseWithTransport |
|
36 |
from breezy.workingtree import WorkingTree |
|
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
37 |
|
38 |
||
|
5283.4.5
by Martin Pool
Update remaining subclasses of ExternalBase |
39 |
class TestCommands(TestCaseWithTransport): |
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
40 |
|
|
2104.1.2
by John Arbash Meinel
(Kent Gibson) Fix bug #4559, strip trailing slashes from ignore patterns |
41 |
def test_ignore_absolutes(self): |
42 |
"""'ignore' with an absolute path returns an error""" |
|
|
2795.2.1
by Daniel Watkins
Updated tests in tests.blackbox.test_ignore to use bzr internals where appropriate. |
43 |
self.make_branch_and_tree('.') |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
44 |
self.run_bzr_error(('brz: ERROR: NAME_PATTERN should not ' |
|
2104.1.2
by John Arbash Meinel
(Kent Gibson) Fix bug #4559, strip trailing slashes from ignore patterns |
45 |
'be an absolute path\n',), |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
46 |
'ignore /crud') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
47 |
|
|
2104.1.2
by John Arbash Meinel
(Kent Gibson) Fix bug #4559, strip trailing slashes from ignore patterns |
48 |
def test_ignore_directories(self): |
49 |
"""ignoring a directory should ignore directory tree. |
|
50 |
||
51 |
Also check that trailing slashes on directories are stripped.
|
|
52 |
"""
|
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
53 |
self.run_bzr('init') |
|
2104.1.2
by John Arbash Meinel
(Kent Gibson) Fix bug #4559, strip trailing slashes from ignore patterns |
54 |
self.build_tree(['dir1/', 'dir1/foo', |
55 |
'dir2/', 'dir2/bar', |
|
56 |
'dir3/', 'dir3/baz']) |
|
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
57 |
self.run_bzr(['ignore', 'dir1', 'dir2/', 'dir4\\']) |
|
2298.8.3
by Kent Gibson
Extended test cases to test bug 86451. |
58 |
self.check_file_contents('.bzrignore', 'dir1\ndir2\ndir4\n') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
59 |
self.assertEqual(self.run_bzr('unknowns')[0], 'dir3\n') |
|
2104.1.2
by John Arbash Meinel
(Kent Gibson) Fix bug #4559, strip trailing slashes from ignore patterns |
60 |
|
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
61 |
def test_ignore_patterns(self): |
|
2795.2.1
by Daniel Watkins
Updated tests in tests.blackbox.test_ignore to use bzr internals where appropriate. |
62 |
tree = self.make_branch_and_tree('.') |
63 |
||
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
64 |
self.assertEqual(list(tree.unknowns()), []) |
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
65 |
|
|
1836.1.15
by John Arbash Meinel
Updated WorkingTree to use the new user-level ignores. |
66 |
# is_ignored() will now create the user global ignore file
|
67 |
# if it doesn't exist, so make sure we ignore it in our tests
|
|
|
1987.1.2
by John Arbash Meinel
Remove the unneeded _set_user_ignores(['./.bazaar']) now that home has moved |
68 |
ignores._set_user_ignores(['*.tmp']) |
|
1836.1.15
by John Arbash Meinel
Updated WorkingTree to use the new user-level ignores. |
69 |
|
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
70 |
self.build_tree_contents( |
|
2795.2.1
by Daniel Watkins
Updated tests in tests.blackbox.test_ignore to use bzr internals where appropriate. |
71 |
[('foo.tmp', '.tmp files are ignored by default')]) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
72 |
self.assertEqual(list(tree.unknowns()), []) |
|
2795.2.1
by Daniel Watkins
Updated tests in tests.blackbox.test_ignore to use bzr internals where appropriate. |
73 |
|
74 |
self.build_tree_contents([('foo.c', 'int main() {}')]) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
75 |
self.assertEqual(list(tree.unknowns()), ['foo.c']) |
|
2795.2.1
by Daniel Watkins
Updated tests in tests.blackbox.test_ignore to use bzr internals where appropriate. |
76 |
|
77 |
tree.add('foo.c') |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
78 |
self.assertEqual(list(tree.unknowns()), []) |
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
79 |
|
80 |
# 'ignore' works when creating the .bzrignore file
|
|
|
2795.2.1
by Daniel Watkins
Updated tests in tests.blackbox.test_ignore to use bzr internals where appropriate. |
81 |
self.build_tree_contents([('foo.blah', 'blah')]) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
82 |
self.assertEqual(list(tree.unknowns()), ['foo.blah']) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
83 |
self.run_bzr('ignore *.blah') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
84 |
self.assertEqual(list(tree.unknowns()), []) |
|
2063.5.4
by wang
Copy Kent Gibson's changes that incorporates John Arbash Meinel's |
85 |
self.check_file_contents('.bzrignore', '*.blah\n') |
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
86 |
|
87 |
# 'ignore' works when then .bzrignore file already exists
|
|
|
2795.2.1
by Daniel Watkins
Updated tests in tests.blackbox.test_ignore to use bzr internals where appropriate. |
88 |
self.build_tree_contents([('garh', 'garh')]) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
89 |
self.assertEqual(list(tree.unknowns()), ['garh']) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
90 |
self.run_bzr('ignore garh') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
91 |
self.assertEqual(list(tree.unknowns()), []) |
|
2063.5.4
by wang
Copy Kent Gibson's changes that incorporates John Arbash Meinel's |
92 |
self.check_file_contents('.bzrignore', '*.blah\ngarh\n') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
93 |
|
|
2104.1.2
by John Arbash Meinel
(Kent Gibson) Fix bug #4559, strip trailing slashes from ignore patterns |
94 |
def test_ignore_multiple_arguments(self): |
|
2063.5.4
by wang
Copy Kent Gibson's changes that incorporates John Arbash Meinel's |
95 |
"""'ignore' works with multiple arguments""" |
|
2795.2.1
by Daniel Watkins
Updated tests in tests.blackbox.test_ignore to use bzr internals where appropriate. |
96 |
tree = self.make_branch_and_tree('.') |
|
2063.5.4
by wang
Copy Kent Gibson's changes that incorporates John Arbash Meinel's |
97 |
self.build_tree(['a','b','c','d']) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
98 |
self.assertEqual(list(tree.unknowns()), ['a', 'b', 'c', 'd']) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
99 |
self.run_bzr('ignore a b c') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
100 |
self.assertEqual(list(tree.unknowns()), ['d']) |
|
2063.5.4
by wang
Copy Kent Gibson's changes that incorporates John Arbash Meinel's |
101 |
self.check_file_contents('.bzrignore', 'a\nb\nc\n') |
|
2077.1.2
by Kent Gibson
Strip trailing slashes from ignore patterns (#4559). |
102 |
|
103 |
def test_ignore_no_arguments(self): |
|
104 |
"""'ignore' with no arguments returns an error""" |
|
|
2795.2.1
by Daniel Watkins
Updated tests in tests.blackbox.test_ignore to use bzr internals where appropriate. |
105 |
self.make_branch_and_tree('.') |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
106 |
self.run_bzr_error(('brz: ERROR: ignore requires at least one ' |
|
5168.3.3
by Parth Malwankar
Removed --old-default-rules flag. |
107 |
'NAME_PATTERN or --default-rules.\n',), |
|
2077.1.2
by Kent Gibson
Strip trailing slashes from ignore patterns (#4559). |
108 |
'ignore') |
109 |
||
|
5168.3.1
by Parth Malwankar
bzr ignore now support --default-rules option |
110 |
def test_ignore_default_rules(self): |
111 |
out, err = self.run_bzr(['ignore', '--default-rules']) |
|
112 |
reference_set = set(ignores.USER_DEFAULTS) |
|
113 |
output_set = set(out.rstrip().split('\n')) |
|
114 |
self.assertEqual(reference_set, output_set) |
|
115 |
self.assertEqual('', err) |
|
116 |
||
|
2747.5.2
by Daniel Watkins
Added tests for new functionality. |
117 |
def test_ignore_versioned_file(self): |
118 |
tree = self.make_branch_and_tree('.') |
|
119 |
self.build_tree(['a','b']) |
|
120 |
tree.add('a') |
|
121 |
||
122 |
# test a single versioned file
|
|
123 |
out, err = self.run_bzr('ignore a') |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
124 |
self.assertEqual(out, |
|
2747.5.2
by Daniel Watkins
Added tests for new functionality. |
125 |
"Warning: the following files are version controlled"\
|
|
4098.6.1
by Neil Martinsen-Burrell
Use a more informative message when an ignore pattern matches existing version controlled files. Fixes #248895 |
126 |
" and match your ignore pattern:\na\n"\ |
127 |
"These files will continue to be version controlled"\
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
128 |
" unless you 'brz remove' them.\n") |
|
2747.5.2
by Daniel Watkins
Added tests for new functionality. |
129 |
|
130 |
# test a single unversioned file
|
|
131 |
out, err = self.run_bzr('ignore b') |
|
132 |
self.assertEqual(out, '') |
|
133 |
||
134 |
# test wildcards
|
|
135 |
tree.add('b') |
|
136 |
out, err = self.run_bzr('ignore *') |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
137 |
self.assertEqual(out, |
|
2747.5.2
by Daniel Watkins
Added tests for new functionality. |
138 |
"Warning: the following files are version controlled"\
|
|
4098.6.1
by Neil Martinsen-Burrell
Use a more informative message when an ignore pattern matches existing version controlled files. Fixes #248895 |
139 |
" and match your ignore pattern:\n.bzrignore\na\nb\n"\ |
140 |
"These files will continue to be version controlled"\
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
141 |
" unless you 'brz remove' them.\n") |
|
2747.5.4
by Daniel Watkins
Added test showing that the warning lists only files matching the new glob, as per abentley's request. |
142 |
|
143 |
def test_ignored_versioned_file_matching_new_pattern(self): |
|
144 |
tree = self.make_branch_and_tree('.') |
|
145 |
self.build_tree(['a', 'b']) |
|
146 |
tree.add(['a', 'b']) |
|
147 |
self.run_bzr('ignore *') |
|
148 |
||
149 |
# If only the given pattern is used then only 'b' should match in
|
|
150 |
# this case.
|
|
151 |
out, err = self.run_bzr('ignore b') |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
152 |
self.assertEqual(out, |
|
2747.5.4
by Daniel Watkins
Added test showing that the warning lists only files matching the new glob, as per abentley's request. |
153 |
"Warning: the following files are version controlled"\
|
|
4098.6.1
by Neil Martinsen-Burrell
Use a more informative message when an ignore pattern matches existing version controlled files. Fixes #248895 |
154 |
" and match your ignore pattern:\nb\n"\ |
155 |
"These files will continue to be version controlled"\
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
156 |
" unless you 'brz remove' them.\n") |
|
5171.3.7
by Martin von Gagern
Added blackbox tests for --directory option. |
157 |
|
158 |
def test_ignore_directory(self): |
|
159 |
"""Test --directory option""" |
|
160 |
tree = self.make_branch_and_tree('a') |
|
161 |
self.run_bzr(['ignore', '--directory=a', 'README']) |
|
162 |
self.check_file_contents('a/.bzrignore', 'README\n') |
|
|
5339.3.4
by Parth Malwankar
cleanup of globster code. |
163 |
|
164 |
def test_ignored_invalid_pattern(self): |
|
165 |
"""Ensure graceful handling for invalid ignore pattern. |
|
166 |
||
167 |
Test case for #300062.
|
|
168 |
Invalid pattern should show clear error message.
|
|
169 |
Invalid pattern should not be added to .bzrignore file.
|
|
170 |
"""
|
|
171 |
tree = self.make_branch_and_tree('.') |
|
172 |
out, err = self.run_bzr(['ignore', 'RE:*.cpp', 'foo', 'RE:['], 3) |
|
173 |
self.assertEqual(out, '') |
|
174 |
self.assertContainsRe(err, |
|
175 |
'Invalid ignore pattern.*RE:\*\.cpp.*RE:\[', re.DOTALL) |
|
176 |
self.assertNotContainsRe(err, 'foo', re.DOTALL) |
|
177 |
self.assertFalse(os.path.isfile('.bzrignore')) |
|
178 |