44
44
class TestCommands(ExternalBase):
46
def test_ignore_absolutes(self):
47
"""'ignore' with an absolute path returns an error"""
49
self.run_bzr_error(('bzr: ERROR: NAME_PATTERN should not '
50
'be an absolute path\n',),
53
def test_ignore_directories(self):
54
"""ignoring a directory should ignore directory tree.
56
Also check that trailing slashes on directories are stripped.
59
self.build_tree(['dir1/', 'dir1/foo',
62
self.runbzr('ignore dir1 dir2/')
63
self.check_file_contents('.bzrignore', 'dir1\ndir2\n')
64
self.assertEquals(self.capture('unknowns'), 'dir3\n')
46
66
def test_ignore_patterns(self):
47
67
self.runbzr('init')
48
68
self.assertEquals(self.capture('unknowns'), '')
67
87
self.assertEquals(self.capture('unknowns'), 'foo.blah\n')
68
88
self.runbzr('ignore *.blah')
69
89
self.assertEquals(self.capture('unknowns'), '')
70
self.assertEquals('*.blah\n', open('.bzrignore', 'rU').read())
90
self.check_file_contents('.bzrignore', '*.blah\n')
72
92
# 'ignore' works when then .bzrignore file already exists
73
93
file('garh', 'wt').write('garh')
74
94
self.assertEquals(self.capture('unknowns'), 'garh\n')
75
95
self.runbzr('ignore garh')
76
96
self.assertEquals(self.capture('unknowns'), '')
77
self.assertEquals(file('.bzrignore', 'rU').read(), '*.blah\ngarh\n')
97
self.check_file_contents('.bzrignore', '*.blah\ngarh\n')
99
def test_ignore_multiple_arguments(self):
100
"""'ignore' works with multiple arguments"""
102
self.build_tree(['a','b','c','d'])
103
self.assertEquals(self.capture('unknowns'), 'a\nb\nc\nd\n')
104
self.runbzr('ignore a b c')
105
self.assertEquals(self.capture('unknowns'), 'd\n')
106
self.check_file_contents('.bzrignore', 'a\nb\nc\n')
108
def test_ignore_no_arguments(self):
109
"""'ignore' with no arguments returns an error"""
111
self.run_bzr_error(('bzr: ERROR: ignore requires at least one '
112
'NAME_PATTERN or --old-default-rules\n',),
79
115
def test_ignore_old_defaults(self):
80
116
out, err = self.run_bzr('ignore', '--old-default-rules')
81
117
self.assertContainsRe(out, 'CVS')
82
118
self.assertEqual('', err)