~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merged mailine

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
from bzrlib.branch import Branch
44
44
from bzrlib.clone import copy_branch
45
45
from bzrlib.errors import BzrCommandError
46
 
from bzrlib.osutils import has_symlinks
 
46
from bzrlib.osutils import has_symlinks, pathjoin
47
47
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
 
48
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
48
49
from bzrlib.tests.blackbox import ExternalBase
49
50
 
50
51
class TestCommands(ExternalBase):
215
216
        os.rmdir('revertdir')
216
217
        self.runbzr('revert')
217
218
 
218
 
        os.symlink('/unlikely/to/exist', 'symlink')
219
 
        self.runbzr('add symlink')
220
 
        self.runbzr('commit -m f')
221
 
        os.unlink('symlink')
222
 
        self.runbzr('revert')
223
 
        self.failUnlessExists('symlink')
224
 
        os.unlink('symlink')
225
 
        os.symlink('a-different-path', 'symlink')
226
 
        self.runbzr('revert')
227
 
        self.assertEqual('/unlikely/to/exist',
228
 
                         os.readlink('symlink'))
 
219
        if has_symlinks():
 
220
            os.symlink('/unlikely/to/exist', 'symlink')
 
221
            self.runbzr('add symlink')
 
222
            self.runbzr('commit -m f')
 
223
            os.unlink('symlink')
 
224
            self.runbzr('revert')
 
225
            self.failUnlessExists('symlink')
 
226
            os.unlink('symlink')
 
227
            os.symlink('a-different-path', 'symlink')
 
228
            self.runbzr('revert')
 
229
            self.assertEqual('/unlikely/to/exist',
 
230
                             os.readlink('symlink'))
 
231
        else:
 
232
            self.log("skipping revert symlink tests")
229
233
        
230
234
        file('hello', 'wt').write('xyz')
231
235
        self.runbzr('commit -m xyz hello')
342
346
        zf = ZipFile('../first-zip')
343
347
        self.assert_('first-zip/hello' in zf.namelist(), zf.namelist())
344
348
 
345
 
    def test_diff(self):
346
 
        self.example_branch()
347
 
        file('hello', 'wt').write('hello world!')
348
 
        self.runbzr('commit -m fixing hello')
349
 
        output = self.runbzr('diff -r 2..3', backtick=1, retcode=1)
350
 
        self.assert_('\n+hello world!' in output)
351
 
        output = self.runbzr('diff -r last:3..last:1', backtick=1, retcode=1)
352
 
        self.assert_('\n+baz' in output)
353
 
        file('moo', 'wb').write('moo')
354
 
        self.runbzr('add moo')
355
 
        os.unlink('moo')
356
 
        self.runbzr('diff')
357
 
 
358
 
    def test_diff_branches(self):
359
 
        self.build_tree(['branch1/', 'branch1/file', 'branch2/'], line_endings='binary')
360
 
        branch = Branch.initialize('branch1')
361
 
        branch.working_tree().add(['file'])
362
 
        branch.working_tree().commit('add file')
363
 
        copy_branch(branch, 'branch2')
364
 
        print >> open('branch2/file', 'wb'), 'new content'
365
 
        branch2 = Branch.open('branch2')
366
 
        branch2.working_tree().commit('update file')
367
 
        # should open branch1 and diff against branch2, 
368
 
        output = self.run_bzr_captured(['diff', '-r', 'branch:branch2', 
369
 
                                        'branch1'],
370
 
                                       retcode=1)
371
 
        self.assertEquals(("=== modified file 'file'\n"
372
 
                           "--- file\t\n"
373
 
                           "+++ file\t\n"
374
 
                           "@@ -1,1 +1,1 @@\n"
375
 
                           "-new content\n"
376
 
                           "+contents of branch1/file\n"
377
 
                           "\n", ''), output)
378
 
        output = self.run_bzr_captured(['diff', 'branch2', 'branch1'],
379
 
                                       retcode=1)
380
 
        self.assertEqualDiff(("=== modified file 'file'\n"
381
 
                              "--- file\t\n"
382
 
                              "+++ file\t\n"
383
 
                              "@@ -1,1 +1,1 @@\n"
384
 
                              "-new content\n"
385
 
                              "+contents of branch1/file\n"
386
 
                              "\n", ''), output)
387
 
 
388
 
 
389
349
    def test_branch(self):
390
350
        """Branch from one branch to another."""
391
351
        os.mkdir('a')
674
634
        self.assertEquals(['If you wish to add some of these files, please'\
675
635
                           ' add them by name.',
676
636
                           'added dir',
677
 
                           'added dir'+os.sep+'sub.txt',
 
637
                           'added dir/sub.txt',
678
638
                           'added top.txt',
679
639
                           'ignored 1 file(s) matching "CVS"'],
680
640
                          results)
728
688
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
729
689
        self.assertEquals(self.capture('unknowns'), 'inertiatic\n')
730
690
        self.run_bzr('add', '--no-recurse', 'inertiatic')
731
 
        self.assertEquals(self.capture('unknowns'), 'inertiatic'+os.sep+'esp\n')
 
691
        self.assertEquals(self.capture('unknowns'), 'inertiatic/esp\n')
732
692
        self.run_bzr('add', 'inertiatic/esp')
733
693
        self.assertEquals(self.capture('unknowns'), '')
734
694
 
1007
967
        runbzr('init')
1008
968
 
1009
969
        self.assertEquals(capture('root').rstrip(),
1010
 
                          os.path.join(self.test_dir, 'branch1'))
 
970
                          pathjoin(self.test_dir, 'branch1'))
1011
971
 
1012
972
        progress("status of new file")
1013
973
 
1083
1043
        runbzr("rename sub1 sub2")
1084
1044
        runbzr("move hello.txt sub2")
1085
1045
        self.assertEqual(capture("relpath sub2/hello.txt"),
1086
 
                         os.path.join("sub2", "hello.txt\n"))
 
1046
                         pathjoin("sub2", "hello.txt\n"))
1087
1047
 
1088
1048
        self.assert_(exists("sub2"))
1089
1049
        self.assert_(exists("sub2/hello.txt"))
1105
1065
 
1106
1066
        chdir('sub1/sub2')
1107
1067
        self.assertEquals(capture('root')[:-1],
1108
 
                          os.path.join(self.test_dir, 'branch1'))
 
1068
                          pathjoin(self.test_dir, 'branch1'))
1109
1069
        runbzr('move ../hello.txt .')
1110
1070
        self.assert_(exists('./hello.txt'))
1111
1071
        self.assertEquals(capture('relpath hello.txt'),
1112
 
                          os.path.join('sub1', 'sub2', 'hello.txt') + '\n')
1113
 
        self.assertEquals(capture('relpath ../../sub1/sub2/hello.txt'), os.path.join('sub1', 'sub2', 'hello.txt\n'))
 
1072
                          pathjoin('sub1', 'sub2', 'hello.txt') + '\n')
 
1073
        self.assertEquals(capture('relpath ../../sub1/sub2/hello.txt'), pathjoin('sub1', 'sub2', 'hello.txt\n'))
1114
1074
        runbzr(['commit', '-m', 'move to parent directory'])
1115
1075
        chdir('..')
1116
 
        self.assertEquals(capture('relpath sub2/hello.txt'), os.path.join('sub1', 'sub2', 'hello.txt\n'))
 
1076
        self.assertEquals(capture('relpath sub2/hello.txt'), pathjoin('sub1', 'sub2', 'hello.txt\n'))
1117
1077
 
1118
1078
        runbzr('move sub2/hello.txt .')
1119
1079
        self.assert_(exists('hello.txt'))
1263
1223
            progress("skipping symlink tests")
1264
1224
 
1265
1225
 
1266
 
class HttpTests(TestCaseWithWebserver):
 
1226
class RemoteTests(object):
1267
1227
    """Test bzr ui commands against remote branches."""
1268
1228
 
1269
1229
    def test_branch(self):
1291
1251
        branch.working_tree().commit('add file', rev_id='A')
1292
1252
        url = self.get_remote_url('branch/')
1293
1253
        self.run_bzr('check', url)
 
1254
    
 
1255
    
 
1256
class HTTPTests(TestCaseWithWebserver, RemoteTests):
 
1257
    """Test various commands against a HTTP server."""
 
1258
    
 
1259
    
 
1260
class SFTPTestsAbsolute(TestCaseWithSFTPServer, RemoteTests):
 
1261
    """Test various commands against a SFTP server using abs paths."""
 
1262
 
 
1263
    
 
1264
class SFTPTestsAbsoluteSibling(TestCaseWithSFTPServer, RemoteTests):
 
1265
    """Test various commands against a SFTP server using abs paths."""
 
1266
 
 
1267
    def setUp(self):
 
1268
        super(SFTPTestsAbsoluteSibling, self).setUp()
 
1269
        self._override_home = '/dev/noone/runs/tests/here'
 
1270
 
 
1271
    
 
1272
class SFTPTestsRelative(TestCaseWithSFTPServer, RemoteTests):
 
1273
    """Test various commands against a SFTP server using homedir rel paths."""
 
1274
 
 
1275
    def setUp(self):
 
1276
        super(SFTPTestsRelative, self).setUp()
 
1277
        self._get_remote_is_absolute = False