/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_aliases.py

  • Committer: Michael Ellerman
  • Date: 2006-03-09 00:24:48 UTC
  • mto: (1610.1.8 bzr.mbp.integration)
  • mto: This revision was merged to the branch mainline in revision 1616.
  • Revision ID: michael@ellerman.id.au-20060309002448-70cce15e3d605130
Make the "ignore line" in the commit message editor the "right" width, so
that if you make your message that wide it won't wrap in bzr log output.
Just as a visual aid.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Black-box tests for bzr aliases.
 
2
"""
 
3
 
 
4
import os
 
5
 
 
6
from bzrlib.branch import Branch
 
7
from bzrlib.tests import TestCaseInTempDir
 
8
from bzrlib.trace import mutter
 
9
from bzrlib.config import (config_dir, config_filename)
 
10
 
 
11
 
 
12
class TestAliases(TestCaseInTempDir):
 
13
 
 
14
    def test_aliases(self):
 
15
 
 
16
        def bzr(*args, **kwargs):
 
17
            return self.run_bzr(*args, **kwargs)[0]
 
18
 
 
19
        def bzr_catch_error(*args, **kwargs):
 
20
            return self.run_bzr(*args, **kwargs)[1]
 
21
 
 
22
 
 
23
        if os.path.isfile(config_filename()):
 
24
            # Something is wrong in environment, 
 
25
            # we risk overwriting users config 
 
26
            self.assert_(config_filename() + "exists, abort")
 
27
            
 
28
        os.mkdir(config_dir())
 
29
        CONFIG=("[ALIASES]\n"
 
30
                "c=cat\n"
 
31
                "c1=cat -r 1\n"
 
32
                "c2=cat -r 1 -r2\n")
 
33
 
 
34
        open(config_filename(),'wb').write(CONFIG)
 
35
 
 
36
 
 
37
        str1 = 'foo\n'
 
38
        str2 = 'bar\n'
 
39
 
 
40
        bzr('init')
 
41
        open('a', 'wb').write(str1)
 
42
        bzr('add', 'a')
 
43
 
 
44
        bzr('commit', '-m', '1')
 
45
 
 
46
        self.assertEquals(bzr('c', 'a'), str1)
 
47
 
 
48
        open('a', 'wb').write(str2)
 
49
        bzr('commit', '-m', '2')
 
50
 
 
51
        self.assertEquals(bzr('c', 'a'), str2)
 
52
        self.assertEquals(bzr('c1', 'a'), str1)
 
53
        self.assertEquals(bzr('c1', '--revision', '2', 'a'), str2)
 
54
 
 
55
        # If --no-aliases isn't working, we will not get retcode=3
 
56
        bzr('--no-aliases', 'c', 'a', retcode=3)
 
57
 
 
58
        # If --no-aliases breaks all of bzr, we also get retcode=3
 
59
        # So we need to catch the output as well
 
60
        self.assertEquals(bzr_catch_error('--no-aliases', 'c', 'a', 
 
61
                                          retcode=None), 
 
62
                          "bzr: ERROR: unknown command 'c'\n")
 
63
 
 
64
        bzr('c', '-r1', '-r2', retcode=3)
 
65
        bzr('c1', '-r1', '-r2', retcode=3)
 
66
        bzr('c2', retcode=3)
 
67
        bzr('c2', '-r1', retcode=3)