1
# Copyright (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2006, 2007, 2009, 2010, 2016 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
"""Black-box tests for bzr aliases.
16
"""Black-box tests for brz aliases.
21
from bzrlib.branch import Branch
22
from bzrlib.tests.blackbox import ExternalBase
23
from bzrlib.trace import mutter
24
from bzrlib.config import (ensure_config_dir_exists, config_filename)
27
class TestAliases(ExternalBase):
21
from breezy import config
22
from breezy.branch import Branch
23
from breezy.tests import TestCaseWithTransport
24
from breezy.trace import mutter
27
class TestAliases(TestCaseWithTransport):
29
29
def test_aliases(self):
35
35
return self.run_bzr(args, **kwargs)[1]
38
if os.path.isfile(config_filename()):
39
# Something is wrong in environment,
40
# we risk overwriting users config
41
self.assert_(config_filename() + "exists, abort")
43
ensure_config_dir_exists()
49
open(config_filename(),'wb').write(CONFIG)
38
conf = config.GlobalConfig.from_string(b'''[ALIASES]
54
47
tree = self.make_branch_and_tree('.')
55
48
self.build_tree_contents([('a', str1)])
57
50
tree.commit(message='1')
59
self.assertEquals(bzr('c a'), str1)
52
self.assertEqual(bzr('c a'), str1)
61
54
self.build_tree_contents([('a', str2)])
62
55
tree.commit(message='2')
64
self.assertEquals(bzr('c a'), str2)
65
self.assertEquals(bzr('c1 a'), str1)
66
self.assertEquals(bzr('c1 --revision 2 a'), str2)
57
self.assertEqual(bzr('c a'), str2)
58
self.assertEqual(bzr('c1 a'), str1)
59
self.assertEqual(bzr('c1 --revision 2 a'), str2)
68
61
# If --no-aliases isn't working, we will not get retcode=3
69
62
bzr('--no-aliases c a', retcode=3)
71
64
# If --no-aliases breaks all of bzr, we also get retcode=3
72
65
# So we need to catch the output as well
73
self.assertEquals(bzr_catch_error('--no-aliases c a',
66
self.assertEqual(bzr_catch_error('--no-aliases c a',
75
'bzr: ERROR: unknown command "c"\n')
68
'brz: ERROR: unknown command "c". '
69
'Perhaps you meant "ci"\n')
77
71
bzr('c -r1 -r2', retcode=3)
78
72
bzr('c1 -r1 -r2', retcode=3)