1
# Copyright (C) 2006 Canonical Ltd
2
# -*- coding: utf-8 -*-
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
"""Black-box tests for running bzr outside of a working tree."""
30
class TestOutsideWT(tests.ChrootedTestCase):
31
"""Test that bzr gives proper errors outside of a working tree."""
33
def test_cwd_log(self):
34
tmp_dir = osutils.mkdtemp()
35
self.addCleanup(lambda: osutils.rmtree(tmp_dir))
36
self.addCleanup(lambda: os.chdir('..'))
38
out, err = self.run_bzr('log', retcode=3)
39
self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n'
40
% (osutils.getcwd(),),
43
def test_url_log(self):
44
url = self.get_readonly_url() + 'subdir/'
45
out, err = self.run_bzr(['log', url], retcode=3)
46
self.assertEqual(u'bzr: ERROR: Not a branch:'
47
u' "%s".\n' % url, err)
49
def test_diff_outside_tree(self):
50
tmp_dir = osutils.mkdtemp()
51
self.addCleanup(lambda: osutils.rmtree(tmp_dir))
52
self.addCleanup(lambda: os.chdir('..'))
54
self.run_bzr('init branch1')
55
self.run_bzr(['commit', '-m', 'nothing',
56
'--unchanged', 'branch1'])
57
self.run_bzr(['commit', '-m', 'nothing',
58
'--unchanged', 'branch1'])
59
this_dir = osutils.getcwd()
60
branch2 = "%s/branch2" % (this_dir,)
62
out, err = self.run_bzr('diff -r revno:2:branch2..revno:1', retcode=3)
63
self.assertEquals('', out)
64
self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (branch2,),
67
out, err = self.run_bzr('diff -r revno:2:branch2', retcode=3)
68
self.assertEquals('', out)
69
self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (branch2,),
72
out, err = self.run_bzr('diff -r revno:2:branch2..', retcode=3)
73
self.assertEquals('', out)
74
self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (branch2,),
77
out, err = self.run_bzr('diff', retcode=3)
78
self.assertEquals('', out)
79
self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (this_dir,),