/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
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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
1551.2.45 by abentley
Fixed outside working tree tests
22
import tempfile
1185.62.15 by John Arbash Meinel
Adding fix + test for correct error message when not in branch.
23
3199.1.3 by Vincent Ladeuil
Fix two more leaked tmp dirs.
24
from bzrlib import (
25
    osutils,
26
    tests,
27
    urlutils,
28
    )
29
30
31
class TestOutsideWT(tests.ChrootedTestCase):
1185.62.15 by John Arbash Meinel
Adding fix + test for correct error message when not in branch.
32
    """Test that bzr gives proper errors outside of a working tree."""
33
1534.4.31 by Robert Collins
cleanedup test_outside_wt
34
    def test_cwd_log(self):
3199.1.3 by Vincent Ladeuil
Fix two more leaked tmp dirs.
35
        tmp_dir = tempfile.mkdtemp()
36
        self.addCleanup(lambda: osutils.rmtree(tmp_dir))
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):
50
        tmp_dir = tempfile.mkdtemp()
51
        self.addCleanup(lambda: osutils.rmtree(tmp_dir))
52
        os.chdir(tmp_dir)
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
53
        self.run_bzr('init branch1')
2552.2.4 by Vincent Ladeuil
Merge bzr.dev and resolve conflits. (good use case for an enhanced merge
54
        self.run_bzr(['commit', '-m', 'nothing',
1881.1.2 by Matthieu Moy
Formatting and style for the last patch.
55
                               '--unchanged', 'branch1'])
2552.2.4 by Vincent Ladeuil
Merge bzr.dev and resolve conflits. (good use case for an enhanced merge
56
        self.run_bzr(['commit', '-m', 'nothing',
1881.1.2 by Matthieu Moy
Formatting and style for the last patch.
57
                               '--unchanged', 'branch1'])
3199.1.3 by Vincent Ladeuil
Fix two more leaked tmp dirs.
58
        this_dir = osutils.getcwd()
3072.1.5 by Ian Clatworthy
more good ideas from abentley
59
        branch2 = "%s/branch2" % (this_dir,)
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
60
        # -r X..Y
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
61
        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.
62
        self.assertEquals('', out)
3072.1.5 by Ian Clatworthy
more good ideas from abentley
63
        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.
64
                         err)
65
        # -r X
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
66
        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.
67
        self.assertEquals('', out)
3072.1.5 by Ian Clatworthy
more good ideas from abentley
68
        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.
69
                         err)
70
        # -r X..
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
71
        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.
72
        self.assertEquals('', out)
3072.1.5 by Ian Clatworthy
more good ideas from abentley
73
        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.
74
                         err)
75
        # no -r at all.
2552.2.2 by Vincent Ladeuil
Enforce run_bzr(string) where possible.
76
        out, err = self.run_bzr('diff', retcode=3)
1881.1.1 by Matthieu Moy
Fixed and tested "bzr diff" outside a working tree.
77
        self.assertEquals('', out)
3072.1.5 by Ian Clatworthy
more good ideas from abentley
78
        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.
79
                         err)