~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/blackbox.py

  • Committer: Robert Collins
  • Date: 2005-09-14 09:01:06 UTC
  • mto: (1185.1.12)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: robertc@robertcollins.net-20050914090106-50ddfad9500a8ae9
make diff lsdiff/filterdiff friendly

Show diffs side-by-side

added added

removed removed

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