/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2010-01-12 03:53:21 UTC
  • mfrom: (4948 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4964.
  • Revision ID: andrew.bennetts@canonical.com-20100112035321-hofpz5p10224ryj3
Merge lp:bzr, resolving conflicts.

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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
# Mr. Smoketoomuch: I'm sorry?
18
18
# Mr. Bounder: You'd better cut down a little then.
22
22
"""Black-box tests for bzr.
23
23
 
24
24
These check that it behaves properly when it's invoked through the regular
25
 
command-line interface. This doesn't actually run a new interpreter but 
 
25
command-line interface. This doesn't actually run a new interpreter but
26
26
rather starts again from the run_bzr function.
27
27
"""
28
28
 
44
44
    )
45
45
from bzrlib.branch import Branch
46
46
from bzrlib.errors import BzrCommandError
47
 
from bzrlib.osutils import (
48
 
    has_symlinks,
49
 
    pathjoin,
50
 
    terminal_width,
51
 
    )
52
47
from bzrlib.tests.http_utils import TestCaseWithWebserver
53
48
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
54
49
from bzrlib.tests.blackbox import ExternalBase
87
82
        os.rmdir('revertdir')
88
83
        self.run_bzr('revert')
89
84
 
90
 
        if has_symlinks():
 
85
        if osutils.has_symlinks():
91
86
            os.symlink('/unlikely/to/exist', 'symlink')
92
87
            self.run_bzr('add symlink')
93
88
            self.run_bzr('commit -m f')
101
96
                             os.readlink('symlink'))
102
97
        else:
103
98
            self.log("skipping revert symlink tests")
104
 
        
 
99
 
105
100
        file('hello', 'wt').write('xyz')
106
101
        self.run_bzr('commit -m xyz hello')
107
102
        self.run_bzr('revert -r 1 hello')
112
107
        self.run_bzr('revert')
113
108
        os.chdir('..')
114
109
 
115
 
    def test_main_version(self):
116
 
        """Check output from version command and master option is reasonable"""
117
 
        # output is intentionally passed through to stdout so that we
118
 
        # can see the version being tested
119
 
        output = self.run_bzr('version')[0]
120
 
        self.log('bzr version output:')
121
 
        self.log(output)
122
 
        self.assert_(output.startswith('Bazaar (bzr) '))
123
 
        self.assertNotEqual(output.index('Canonical'), -1)
124
 
        # make sure --version is consistent
125
 
        tmp_output = self.run_bzr('--version')[0]
126
 
        self.assertEquals(output, tmp_output)
127
 
 
128
110
    def example_branch(test):
129
111
        test.run_bzr('init')
130
112
        file('hello', 'wt').write('foo')
174
156
        added_message = out.find('message:\n  foo')
175
157
        self.failIfEqual(added_message, -1)
176
158
        self.failUnless(added_loc < added_message)
177
 
        
 
159
 
178
160
    def test_locations(self):
179
161
        """Using and remembering different locations"""
180
162
        os.mkdir('a')
202
184
        self.run_bzr('pull', retcode=3)
203
185
        self.run_bzr('pull ../a --remember')
204
186
        self.run_bzr('pull')
205
 
        
 
187
 
206
188
    def test_unknown_command(self):
207
189
        """Handling of unknown command."""
208
190
        out, err = self.run_bzr('fluffy-badger', retcode=3)
315
297
        self.run_bzr('push --overwrite')
316
298
        # nothing missing
317
299
        self.run_bzr('missing ../output-branch')
318
 
        
 
300
 
319
301
        # pushing to a new dir with no parent should fail
320
302
        self.run_bzr('push ../missing/new-branch', retcode=3)
321
303
        # unless we provide --create-prefix
326
308
    def test_external_command(self):
327
309
        """Test that external commands can be run by setting the path
328
310
        """
329
 
        # We don't at present run bzr in a subprocess for blackbox tests, and so 
 
311
        # We don't at present run bzr in a subprocess for blackbox tests, and so
330
312
        # don't really capture stdout, only the internal python stream.
331
313
        # Therefore we don't use a subcommand that produces any output or does
332
 
        # anything -- we just check that it can be run successfully.  
 
314
        # anything -- we just check that it can be run successfully.
333
315
        cmd_name = 'test-command'
334
316
        if sys.platform == 'win32':
335
317
            cmd_name += '.bat'
347
329
            f.close()
348
330
            os.chmod(cmd_name, 0755)
349
331
 
350
 
            # It should not find the command in the local 
 
332
            # It should not find the command in the local
351
333
            # directory by default, since it is not in my path
352
334
            self.run_bzr(cmd_name, retcode=3)
353
335
 
387
369
        self.run_bzr('init')
388
370
 
389
371
        self.assertIsSameRealPath(self.run_bzr('root')[0].rstrip(),
390
 
                                  pathjoin(self.test_dir, 'branch1'))
 
372
                                  osutils.pathjoin(self.test_dir, 'branch1'))
391
373
 
392
374
        progress("status of new file")
393
375
 
433
415
        f.close()
434
416
 
435
417
        self.run_bzr("add hello.txt")
436
 
        
 
418
 
437
419
        f = file('msg.tmp', 'wt')
438
420
        f.write('this is my new commit\nand it has multiple lines, for fun')
439
421
        f.close()
456
438
 
457
439
        log_out = self.run_bzr('log --line')[0]
458
440
        # determine the widest line we want
459
 
        max_width = terminal_width() - 1
460
 
        for line in log_out.splitlines():
461
 
            self.assert_(len(line) <= max_width, len(line))
 
441
        max_width = osutils.terminal_width()
 
442
        if max_width is not None:
 
443
            for line in log_out.splitlines():
 
444
                self.assert_(len(line) <= max_width - 1, len(line))
462
445
        self.assert_("this is my new commit and" not in log_out)
463
446
        self.assert_("this is my new commit" in log_out)
464
447
 
475
458
 
476
459
        self.run_bzr('info')
477
460
 
478
 
        if has_symlinks():
 
461
        if osutils.has_symlinks():
479
462
            progress("symlinks")
480
463
            mkdir('symlinks')
481
464
            chdir('symlinks')
602
585
        url = self.get_readonly_url('branch/file')
603
586
        output = self.run_bzr('log %s' % url)[0]
604
587
        self.assertEqual(8, len(output.split('\n')))
605
 
        
 
588
 
606
589
    def test_check(self):
607
590
        self.build_tree(['branch/', 'branch/file'])
608
591
        self.run_bzr('init branch')[0]
610
593
        self.run_bzr('commit -m foo branch')[0]
611
594
        url = self.get_readonly_url('branch/')
612
595
        self.run_bzr(['check', url])
613
 
    
 
596
 
614
597
    def test_push(self):
615
598
        # create a source branch
616
599
        os.mkdir('my-branch')
623
606
        # with an explicit target work
624
607
        self.run_bzr(['push', self.get_url('output-branch')])
625
608
 
626
 
    
 
609
 
627
610
class HTTPTests(TestCaseWithWebserver, RemoteTests):
628
611
    """Test various commands against a HTTP server."""
629
 
    
630
 
    
 
612
 
 
613
 
631
614
class SFTPTestsAbsolute(TestCaseWithSFTPServer, RemoteTests):
632
615
    """Test various commands against a SFTP server using abs paths."""
633
616
 
634
 
    
 
617
 
635
618
class SFTPTestsAbsoluteSibling(TestCaseWithSFTPServer, RemoteTests):
636
619
    """Test various commands against a SFTP server using abs paths."""
637
620
 
639
622
        super(SFTPTestsAbsoluteSibling, self).setUp()
640
623
        self._override_home = '/dev/noone/runs/tests/here'
641
624
 
642
 
    
 
625
 
643
626
class SFTPTestsRelative(TestCaseWithSFTPServer, RemoteTests):
644
627
    """Test various commands against a SFTP server using homedir rel paths."""
645
628