~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import os
21
21
 
22
 
from bzrlib import osutils
23
 
from bzrlib.tests import (
24
 
    condition_isinstance,
25
 
    split_suite_by_condition,
26
 
    multiply_tests,
27
 
    SymlinkFeature
 
22
from bzrlib import (
 
23
    osutils,
 
24
    tests,
28
25
    )
29
 
from bzrlib.tests.blackbox import ExternalBase
30
26
 
31
27
 
32
28
def load_tests(standard_tests, module, loader):
33
29
    """Parameterize tests for view-aware vs not."""
34
 
    to_adapt, result = split_suite_by_condition(
35
 
        standard_tests, condition_isinstance(TestAdd))
 
30
    to_adapt, result = tests.split_suite_by_condition(
 
31
        standard_tests, tests.condition_isinstance(TestAdd))
36
32
    scenarios = [
37
33
        ('pre-views', {'branch_tree_format': 'pack-0.92'}),
38
34
        ('view-aware', {'branch_tree_format': 'development6-rich-root'}),
39
35
        ]
40
 
    return multiply_tests(to_adapt, scenarios, result)
41
 
 
42
 
 
43
 
class TestAdd(ExternalBase):
 
36
    return tests.multiply_tests(to_adapt, scenarios, result)
 
37
 
 
38
 
 
39
class TestAdd(tests.TestCaseWithTransport):
44
40
 
45
41
    def make_branch_and_tree(self, dir):
46
 
        return ExternalBase.make_branch_and_tree(self, dir,
47
 
            format=self.branch_tree_format)
 
42
        return super(TestAdd, self).make_branch_and_tree(
 
43
            dir, format=self.branch_tree_format)
48
44
 
49
45
    def test_add_reports(self):
50
46
        """add command prints the names of added files."""
115
111
 
116
112
        eq = self.assertEqual
117
113
        ass = self.assertTrue
118
 
        chdir = os.chdir
119
114
 
120
115
        t = self.make_branch_and_tree('.')
121
116
        b = t.branch
130
125
 
131
126
        # add with no arguments in a subdirectory gets only files below that
132
127
        # subdirectory
133
 
        chdir('src')
134
 
        self.run_bzr('add')
135
 
        self.assertEquals(self.run_bzr('unknowns')[0], 'README\n')
 
128
        self.run_bzr('add', working_dir='src')
 
129
        self.assertEquals('README\n',
 
130
                          self.run_bzr('unknowns', working_dir='src')[0])
136
131
        # reopen to see the new changes
137
 
        t = t.bzrdir.open_workingtree()
 
132
        t = t.bzrdir.open_workingtree('src')
138
133
        versioned = [path for path, entry in t.iter_entries_by_dir()]
139
 
        self.assertEquals(versioned,
140
 
            ['', 'src', 'src/foo.c'])
 
134
        self.assertEquals(versioned, ['', 'src', 'src/foo.c'])
141
135
 
142
136
        # add from the parent directory should pick up all file names
143
 
        chdir('..')
144
137
        self.run_bzr('add')
145
138
        self.assertEquals(self.run_bzr('unknowns')[0], '')
146
139
        self.run_bzr('check')
211
204
        self.assertContainsRe(err, r'ERROR:.*\.bzr.*control file')
212
205
 
213
206
    def test_add_via_symlink(self):
214
 
        self.requireFeature(SymlinkFeature)
 
207
        self.requireFeature(tests.SymlinkFeature)
215
208
        self.make_branch_and_tree('source')
216
209
        self.build_tree(['source/top.txt'])
217
210
        os.symlink('source', 'link')
219
212
        self.assertEquals(out, 'adding top.txt\n')
220
213
 
221
214
    def test_add_symlink_to_abspath(self):
222
 
        self.requireFeature(SymlinkFeature)
 
215
        self.requireFeature(tests.SymlinkFeature)
223
216
        self.make_branch_and_tree('tree')
224
217
        os.symlink(osutils.abspath('target'), 'tree/link')
225
218
        out = self.run_bzr(['add', 'tree/link'])[0]