~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Daniel Watkins
  • Date: 2007-07-31 10:33:33 UTC
  • mto: (2687.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 2689.
  • Revision ID: d.m.watkins@warwick.ac.uk-20070731103333-sdelcaazn0fxgaf3
Added tests for ExtendedTestResult.wasStrictlySuccessful.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
#
17
17
 
18
18
"""Tests of the 'bzr add' command."""
19
19
 
20
20
import os
21
21
 
22
 
from bzrlib.tests import (
23
 
    condition_isinstance,
24
 
    split_suite_by_condition,
25
 
    multiply_tests,
26
 
    )
27
22
from bzrlib.tests.blackbox import ExternalBase
28
23
from bzrlib.tests.test_win32utils import NeedsGlobExpansionFeature
29
24
 
30
25
 
31
 
def load_tests(standard_tests, module, loader):
32
 
    """Parameterize tests for view-aware vs not."""
33
 
    to_adapt, result = split_suite_by_condition(
34
 
        standard_tests, condition_isinstance(TestAdd))
35
 
    scenarios = [
36
 
        ('pre-views', {'branch_tree_format': 'pack-0.92'}),
37
 
        ('view-aware', {'branch_tree_format': 'development-wt6'}),
38
 
        ]
39
 
    return multiply_tests(to_adapt, scenarios, result)
40
 
 
41
 
 
42
26
class TestAdd(ExternalBase):
43
 
 
44
 
    def make_branch_and_tree(self, dir):
45
 
        return ExternalBase.make_branch_and_tree(self, dir,
46
 
            format=self.branch_tree_format)
47
 
 
 
27
        
48
28
    def test_add_reports(self):
49
29
        """add command prints the names of added files."""
50
 
        tree = self.make_branch_and_tree('.')
 
30
        self.run_bzr('init')
51
31
        self.build_tree(['top.txt', 'dir/', 'dir/sub.txt', 'CVS'])
52
32
        self.build_tree_contents([('.bzrignore', 'CVS\n')])
53
33
        out = self.run_bzr('add')[0]
55
35
        results = sorted(out.rstrip('\n').split('\n'))
56
36
        self.assertEquals(['If you wish to add some of these files, please'\
57
37
                           ' add them by name.',
58
 
                           'adding .bzrignore',
59
 
                           'adding dir',
60
 
                           'adding dir/sub.txt',
61
 
                           'adding top.txt',
 
38
                           'added .bzrignore',
 
39
                           'added dir',
 
40
                           'added dir/sub.txt',
 
41
                           'added top.txt',
62
42
                           'ignored 1 file(s).'],
63
43
                          results)
64
44
        out = self.run_bzr('add -v')[0]
70
50
 
71
51
    def test_add_quiet_is(self):
72
52
        """add -q does not print the names of added files."""
73
 
        tree = self.make_branch_and_tree('.')
 
53
        self.run_bzr('init')
74
54
        self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
75
55
        out = self.run_bzr('add -q')[0]
76
56
        # the ordering is not defined at the moment
82
62
 
83
63
        "bzr add" should add the parent(s) as necessary.
84
64
        """
85
 
        tree = self.make_branch_and_tree('.')
 
65
        self.run_bzr('init')
86
66
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
87
67
        self.assertEquals(self.run_bzr('unknowns')[0], 'inertiatic\n')
88
68
        self.run_bzr('add inertiatic/esp')
105
85
 
106
86
        "bzr add" should do this happily.
107
87
        """
108
 
        tree = self.make_branch_and_tree('.')
 
88
        self.run_bzr('init')
109
89
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
110
90
        self.assertEquals(self.run_bzr('unknowns')[0], 'inertiatic\n')
111
91
        self.run_bzr('add --no-recurse inertiatic')
120
100
        eq = self.assertEqual
121
101
        ass = self.assertTrue
122
102
        chdir = os.chdir
123
 
 
 
103
        
124
104
        t = self.make_branch_and_tree('.')
125
105
        b = t.branch
126
106
        self.build_tree(['src/', 'README'])
127
 
 
 
107
        
128
108
        eq(sorted(t.unknowns()),
129
109
           ['README', 'src'])
130
 
 
 
110
        
131
111
        self.run_bzr('add src')
132
 
 
 
112
        
133
113
        self.build_tree(['src/foo.c'])
134
 
 
 
114
        
135
115
        # add with no arguments in a subdirectory gets only files below that
136
116
        # subdirectory
137
117
        chdir('src')
142
122
        versioned = [path for path, entry in t.iter_entries_by_dir()]
143
123
        self.assertEquals(versioned,
144
124
            ['', 'src', 'src/foo.c'])
145
 
 
 
125
                
146
126
        # add from the parent directory should pick up all file names
147
127
        chdir('..')
148
128
        self.run_bzr('add')
166
146
        os.chdir('new')
167
147
        out, err = self.run_bzr('add --file-ids-from ../base')
168
148
        self.assertEqual('', err)
169
 
        self.assertEqualDiff('adding a w/ file id from a\n'
170
 
                             'adding b w/ file id from b\n'
171
 
                             'adding b/c w/ file id from b/c\n',
 
149
        self.assertEqualDiff('added a w/ file id from a\n'
 
150
                             'added b w/ file id from b\n'
 
151
                             'added b/c w/ file id from b/c\n',
172
152
                             out)
173
153
        new_tree = new_tree.bzrdir.open_workingtree()
174
154
        self.assertEqual(base_tree.path2id('a'), new_tree.path2id('a'))
187
167
        os.chdir('new')
188
168
        out, err = self.run_bzr('add --file-ids-from ../base/b')
189
169
        self.assertEqual('', err)
190
 
        self.assertEqualDiff('adding c w/ file id from b/c\n'
191
 
                             'adding d w/ file id from b/d\n',
 
170
        self.assertEqualDiff('added c w/ file id from b/c\n'
 
171
                             'added d w/ file id from b/d\n',
192
172
                             out)
193
173
 
194
174
        new_tree = new_tree.bzrdir.open_workingtree()