/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2052.3.2 by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical
1
# Copyright (C) 2006 Canonical Ltd
1185.62.15 by John Arbash Meinel
Adding fix + test for correct error message when not in branch.
2
# -*- coding: utf-8 -*-
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
3
#
1185.62.15 by John Arbash Meinel
Adding fix + test for correct error message when not in branch.
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.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
8
#
1185.62.15 by John Arbash Meinel
Adding fix + test for correct error message when not in branch.
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.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
13
#
1185.62.15 by John Arbash Meinel
Adding fix + test for correct error message when not in branch.
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
4183.7.1 by Sabin Iacob
update FSF mailing address
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1185.62.15 by John Arbash Meinel
Adding fix + test for correct error message when not in branch.
17
18
1185.62.16 by John Arbash Meinel
Cleanup from Robert Collins.
19
"""Black-box tests for running bzr outside of a working tree."""
1185.62.15 by John Arbash Meinel
Adding fix + test for correct error message when not in branch.
20
21
import os
22
3199.1.3 by Vincent Ladeuil
Fix two more leaked tmp dirs.
23
from bzrlib import (
24
    osutils,
25
    tests,
26
    urlutils,
27
    )
28
29
30
class TestOutsideWT(tests.ChrootedTestCase):
1185.62.15 by John Arbash Meinel
Adding fix + test for correct error message when not in branch.
31
    """Test that bzr gives proper errors outside of a working tree."""
32
1534.4.31 by Robert Collins
cleanedup test_outside_wt
33
    def test_cwd_log(self):
3638.3.2 by Vincent Ladeuil
Fix all calls to tempfile.mkdtemp to osutils.mkdtemp.
34
        tmp_dir = osutils.mkdtemp()
3199.1.3 by Vincent Ladeuil
Fix two more leaked tmp dirs.
35
        self.addCleanup(lambda: osutils.rmtree(tmp_dir))
3619.6.3 by Mark Hammond
ensure we aren't trying to remove the cwd, which fails on Windows.
36
        self.addCleanup(lambda: os.chdir('..'))
3199.1.3 by Vincent Ladeuil
Fix two more leaked tmp dirs.
37
        os.chdir(tmp_dir)
1185.62.15 by John Arbash Meinel
Adding fix + test for correct error message when not in branch.
38
        out, err = self.run_bzr('log', retcode=3)
3199.1.3 by Vincent Ladeuil
Fix two more leaked tmp dirs.
39
        self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n'
40
                         % (osutils.getcwd(),),
1185.62.15 by John Arbash Meinel
Adding fix + test for correct error message when not in branch.
41
                         err)
42
1534.4.31 by Robert Collins
cleanedup test_outside_wt
43
    def test_url_log(self):
44
        url = self.get_readonly_url() + 'subdir/'
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
45
        out, err = self.run_bzr(['log', url], retcode=3)
1534.4.31 by Robert Collins
cleanedup test_outside_wt
46
        self.assertEqual(u'bzr: ERROR: Not a branch:'
2745.3.2 by Daniel Watkins
Updated tests to reflect new error text.
47
                         u' "%s".\n' % url, err)
1881.1.3 by Matthieu Moy
One missing blank line.
48
3199.1.3 by Vincent Ladeuil
Fix two more leaked tmp dirs.
49
    def test_diff_outside_tree(self):
3638.3.2 by Vincent Ladeuil
Fix all calls to tempfile.mkdtemp to osutils.mkdtemp.
50
        tmp_dir = osutils.mkdtemp()
3199.1.3 by Vincent Ladeuil
Fix two more leaked tmp dirs.
51
        self.addCleanup(lambda: osutils.rmtree(tmp_dir))
3619.6.3 by Mark Hammond
ensure we aren't trying to remove the cwd, which fails on Windows.
52
        self.addCleanup(lambda: os.chdir('..'))
3199.1.3 by Vincent Ladeuil
Fix two more leaked tmp dirs.
53
        os.chdir(tmp_dir)
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
54
        self.run_bzr('init branch1')
2552.2.4 by Vincent Ladeuil
Merge bzr.dev and resolve conflits. (good use case for an enhanced merge
55
        self.run_bzr(['commit', '-m', 'nothing',
1881.1.2 by Matthieu Moy
Formatting and style for the last patch.
56
                               '--unchanged', 'branch1'])
2552.2.4 by Vincent Ladeuil
Merge bzr.dev and resolve conflits. (good use case for an enhanced merge
57
        self.run_bzr(['commit', '-m', 'nothing',
1881.1.2 by Matthieu Moy
Formatting and style for the last patch.
58
                               '--unchanged', 'branch1'])
3199.1.3 by Vincent Ladeuil
Fix two more leaked tmp dirs.
59
        this_dir = osutils.getcwd()
3072.1.5 by Ian Clatworthy
more good ideas from abentley
60
        branch2 = "%s/branch2" % (this_dir,)
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
61
        # -r X..Y
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
62
        out, err = self.run_bzr('diff -r revno:2:branch2..revno:1', retcode=3)
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
63
        self.assertEquals('', out)
3072.1.5 by Ian Clatworthy
more good ideas from abentley
64
        self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (branch2,),
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
65
                         err)
66
        # -r X
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
67
        out, err = self.run_bzr('diff -r revno:2:branch2', retcode=3)
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
68
        self.assertEquals('', out)
3072.1.5 by Ian Clatworthy
more good ideas from abentley
69
        self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (branch2,),
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
70
                         err)
71
        # -r X..
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
72
        out, err = self.run_bzr('diff -r revno:2:branch2..', retcode=3)
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
73
        self.assertEquals('', out)
3072.1.5 by Ian Clatworthy
more good ideas from abentley
74
        self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (branch2,),
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
75
                         err)
76
        # no -r at all.
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
77
        out, err = self.run_bzr('diff', retcode=3)
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
78
        self.assertEquals('', out)
3072.1.5 by Ian Clatworthy
more good ideas from abentley
79
        self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (this_dir,),
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
80
                         err)