~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/blackbox.py

  • Committer: Martin Pool
  • Date: 2005-09-01 02:34:38 UTC
  • Revision ID: mbp@sourcefrog.net-20050901023437-bf791a0ef5edae8d
- old docs: clarify that this is not mainly descended from arch anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
"""
28
28
 
29
29
import sys
30
 
import os
31
 
 
32
30
from bzrlib.selftest import TestCaseInTempDir, BzrTestBase
33
 
from bzrlib.branch import Branch
34
 
from bzrlib.commands import run_bzr
35
 
 
36
31
 
37
32
class ExternalBase(TestCaseInTempDir):
38
33
    def runbzr(self, args, retcode=0,backtick=False):
123
118
        assert file('.bzrignore', 'rb').read() == '*.blah\ngarh\n'
124
119
 
125
120
    def test_revert(self):
 
121
        import os
126
122
        self.runbzr('init')
127
123
 
128
124
        file('hello', 'wt').write('foo')
194
190
 
195
191
    def test_merge(self):
196
192
        from bzrlib.branch import Branch
 
193
        import os
197
194
        
198
195
        os.mkdir('a')
199
196
        os.chdir('a')
218
215
        a.get_revision_xml(b.last_patch())
219
216
 
220
217
        self.log('pending merges: %s', a.pending_merges())
221
 
        #        assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
222
 
        #        % (a.pending_merges(), b.last_patch())
223
 
 
224
 
    def test_pull(self):
225
 
        """Pull changes from one branch to another."""
226
 
        os.mkdir('a')
227
 
        os.chdir('a')
228
 
 
229
 
        self.example_branch()
230
 
        os.chdir('..')
231
 
        self.runbzr('branch a b')
232
 
        os.chdir('b')
233
 
        self.runbzr('commit -m blah --unchanged')
234
 
        os.chdir('../a')
235
 
        a = Branch('.')
236
 
        b = Branch('../b')
237
 
        assert a.revision_history() == b.revision_history()[:-1]
238
 
        self.runbzr('pull ../b')
239
 
        assert a.revision_history() == b.revision_history()
240
 
        self.runbzr('commit -m blah2 --unchanged')
241
 
        os.chdir('../b')
242
 
        self.runbzr('commit -m blah3 --unchanged')
243
 
        self.runbzr('pull ../a', retcode=1)
244
 
 
245
 
    def test_add_reports(self):
246
 
        """add command prints the names of added files."""
247
 
        b = Branch('.', init=True)
248
 
        self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
249
 
 
250
 
        from cStringIO import StringIO
251
 
        out = StringIO()
252
 
 
253
 
        ret = self.apply_redirected(None, out, None,
254
 
                                    run_bzr,
255
 
                                    ['add'])
256
 
        self.assertEquals(ret, 0)
257
 
 
258
 
        # the ordering is not defined at the moment
259
 
        results = sorted(out.getvalue().rstrip('\n').split('\n'))
260
 
        self.assertEquals(['added dir',
261
 
                           'added dir/sub.txt',
262
 
                           'added top.txt',],
263
 
                          results)
264
 
 
 
218
#        assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
 
219
#        % (a.pending_merges(), b.last_patch())
265
220
 
266
221
class OldTests(ExternalBase):
267
222
    """old tests moved from ./testbzr."""
269
224
    def test_bzr(self):
270
225
        from os import chdir, mkdir
271
226
        from os.path import exists
 
227
        import os
272
228
 
273
229
        runbzr = self.runbzr
274
230
        backtick = self.backtick