~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_ignore.py

  • Committer: John Arbash Meinel
  • Date: 2006-12-01 19:41:16 UTC
  • mfrom: (2158 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2159.
  • Revision ID: john@arbash-meinel.com-20061201194116-nvn5qhfxux5284jc
[merge] bzr.dev 2158

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 
44
44
class TestCommands(ExternalBase):
45
45
 
 
46
    def test_ignore_absolutes(self):
 
47
        """'ignore' with an absolute path returns an error"""
 
48
        self.runbzr('init')
 
49
        self.run_bzr_error(('bzr: ERROR: NAME_PATTERN should not '
 
50
                            'be an absolute path\n',),
 
51
                           'ignore','/crud')
 
52
        
 
53
    def test_ignore_directories(self):
 
54
        """ignoring a directory should ignore directory tree.
 
55
 
 
56
        Also check that trailing slashes on directories are stripped.
 
57
        """
 
58
        self.runbzr('init')
 
59
        self.build_tree(['dir1/', 'dir1/foo',
 
60
                         'dir2/', 'dir2/bar',
 
61
                         'dir3/', 'dir3/baz'])
 
62
        self.runbzr('ignore dir1 dir2/')
 
63
        self.check_file_contents('.bzrignore', 'dir1\ndir2\n')
 
64
        self.assertEquals(self.capture('unknowns'), 'dir3\n')
 
65
 
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')
71
91
 
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')
78
 
        
 
97
        self.check_file_contents('.bzrignore', '*.blah\ngarh\n')
 
98
       
 
99
    def test_ignore_multiple_arguments(self):
 
100
        """'ignore' works with multiple arguments"""
 
101
        self.runbzr('init')
 
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')
 
107
 
 
108
    def test_ignore_no_arguments(self):
 
109
        """'ignore' with no arguments returns an error"""
 
110
        self.runbzr('init')
 
111
        self.run_bzr_error(('bzr: ERROR: ignore requires at least one '
 
112
                            'NAME_PATTERN or --old-default-rules\n',),
 
113
                           'ignore')
 
114
 
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)
 
119