bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
1 |
# Copyright (C) 2005, 2006 by Canonical Ltd
|
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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""UI tests for bzr ignore."""
|
|
18 |
||
19 |
||
20 |
from cStringIO import StringIO |
|
21 |
import os |
|
22 |
import re |
|
23 |
import sys |
|
24 |
||
|
1836.1.15
by John Arbash Meinel
Updated WorkingTree to use the new user-level ignores. |
25 |
from bzrlib import ignores |
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
26 |
import bzrlib |
27 |
from bzrlib.branch import Branch |
|
28 |
import bzrlib.bzrdir as bzrdir |
|
29 |
from bzrlib.errors import BzrCommandError |
|
30 |
from bzrlib.osutils import ( |
|
31 |
has_symlinks, |
|
32 |
pathjoin, |
|
33 |
rmtree, |
|
34 |
terminal_width, |
|
35 |
)
|
|
36 |
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver |
|
37 |
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer |
|
38 |
from bzrlib.tests.blackbox import ExternalBase |
|
39 |
from bzrlib.workingtree import WorkingTree |
|
40 |
||
41 |
||
42 |
class TestCommands(ExternalBase): |
|
43 |
||
44 |
def test_ignore_patterns(self): |
|
45 |
self.runbzr('init') |
|
46 |
self.assertEquals(self.capture('unknowns'), '') |
|
47 |
||
|
1836.1.15
by John Arbash Meinel
Updated WorkingTree to use the new user-level ignores. |
48 |
# is_ignored() will now create the user global ignore file
|
49 |
# 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 |
50 |
ignores._set_user_ignores(['*.tmp']) |
|
1836.1.15
by John Arbash Meinel
Updated WorkingTree to use the new user-level ignores. |
51 |
|
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
52 |
self.build_tree_contents( |
|
1836.1.15
by John Arbash Meinel
Updated WorkingTree to use the new user-level ignores. |
53 |
[('foo.tmp', '.tmp files are ignored by default'), |
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
54 |
])
|
55 |
self.assertEquals(self.capture('unknowns'), '') |
|
56 |
||
57 |
file('foo.c', 'wt').write('int main() {}') |
|
58 |
self.assertEquals(self.capture('unknowns'), 'foo.c\n') |
|
59 |
||
60 |
self.runbzr(['add', 'foo.c']) |
|
61 |
self.assertEquals(self.capture('unknowns'), '') |
|
62 |
||
63 |
# 'ignore' works when creating the .bzrignore file
|
|
64 |
file('foo.blah', 'wt').write('blah') |
|
65 |
self.assertEquals(self.capture('unknowns'), 'foo.blah\n') |
|
66 |
self.runbzr('ignore *.blah') |
|
67 |
self.assertEquals(self.capture('unknowns'), '') |
|
|
1836.1.15
by John Arbash Meinel
Updated WorkingTree to use the new user-level ignores. |
68 |
self.assertEquals('*.blah\n', open('.bzrignore', 'rU').read()) |
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
69 |
|
70 |
# 'ignore' works when then .bzrignore file already exists
|
|
71 |
file('garh', 'wt').write('garh') |
|
72 |
self.assertEquals(self.capture('unknowns'), 'garh\n') |
|
73 |
self.runbzr('ignore garh') |
|
74 |
self.assertEquals(self.capture('unknowns'), '') |
|
|
1836.1.15
by John Arbash Meinel
Updated WorkingTree to use the new user-level ignores. |
75 |
self.assertEquals(file('.bzrignore', 'rU').read(), '*.blah\ngarh\n') |
|
1765.1.2
by Robert Collins
Add missing test_ignore.py |
76 |
|
77 |
def test_ignore_old_defaults(self): |
|
78 |
out, err = self.run_bzr('ignore', '--old-default-rules') |
|
79 |
self.assertContainsRe(out, 'CVS') |
|
80 |
self.assertEqual('', err) |