1
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
"""Black-box tests for bzr aliases.
21
from bzrlib import config
22
from bzrlib.branch import Branch
23
from bzrlib.tests import TestCaseWithTransport
24
from bzrlib.trace import mutter
27
class TestAliases(TestCaseWithTransport):
29
def test_aliases(self):
31
def bzr(args, **kwargs):
32
return self.run_bzr(args, **kwargs)[0]
34
def bzr_catch_error(args, **kwargs):
35
return self.run_bzr(args, **kwargs)[1]
38
conf = config.GlobalConfig.from_string('''[ALIASES]
47
tree = self.make_branch_and_tree('.')
48
self.build_tree_contents([('a', str1)])
50
tree.commit(message='1')
52
self.assertEquals(bzr('c a'), str1)
54
self.build_tree_contents([('a', str2)])
55
tree.commit(message='2')
57
self.assertEquals(bzr('c a'), str2)
58
self.assertEquals(bzr('c1 a'), str1)
59
self.assertEquals(bzr('c1 --revision 2 a'), str2)
61
# If --no-aliases isn't working, we will not get retcode=3
62
bzr('--no-aliases c a', retcode=3)
64
# If --no-aliases breaks all of bzr, we also get retcode=3
65
# So we need to catch the output as well
66
self.assertEquals(bzr_catch_error('--no-aliases c a',
68
'bzr: ERROR: unknown command "c"\n')
70
bzr('c -r1 -r2', retcode=3)
71
bzr('c1 -r1 -r2', retcode=3)
73
bzr('c2 -r1', retcode=3)