/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_check.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-08-04 12:35:07 UTC
  • mfrom: (4580.4.6 408193-hardlink)
  • Revision ID: pqm@pqm.ubuntu.com-20090804123507-6hzrl27orc90ernc
(mbp) KnownFailure for bug 408193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2007, 2009 Canonical Ltd
 
2
#
 
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.
 
7
#
 
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.
 
12
#
 
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
 
 
17
"""Tests for the 'check' CLI command."""
 
18
 
 
19
from bzrlib.tests import ChrootedTestCase
 
20
from bzrlib.tests.blackbox import ExternalBase
 
21
 
 
22
 
 
23
class TestCheck(ExternalBase):
 
24
 
 
25
    def test_check_no_tree(self):
 
26
        self.make_branch('.')
 
27
        self.run_bzr('check')
 
28
 
 
29
    def test_check_initial_tree(self):
 
30
        self.make_branch_and_tree('.')
 
31
        self.run_bzr('check')
 
32
 
 
33
    def test_check_one_commit_tree(self):
 
34
        tree = self.make_branch_and_tree('.')
 
35
        tree.commit('hallelujah')
 
36
        out, err = self.run_bzr('check')
 
37
        # the root directory may be in the texts for rich root formats
 
38
        self.assertContainsRe(err, r"^Checking working tree at '.*'\.\n"
 
39
                                   r"Checking repository at '.*'\.\n"
 
40
                                   r"checked repository.*\n"
 
41
                                   r"     1 revisions\n"
 
42
                                   r"     [01] file-ids\n"
 
43
                                   r"     0 unique file texts\n"
 
44
                                   r"     0 repeated file texts\n"
 
45
                                   r"     0 unreferenced text versions\n"
 
46
                                   r"Checking branch at '.*'\.\n"
 
47
                                   r"checked branch.*\n$")
 
48
 
 
49
    def test_check_branch(self):
 
50
        tree = self.make_branch_and_tree('.')
 
51
        tree.commit('foo')
 
52
        out, err = self.run_bzr('check --branch')
 
53
        self.assertContainsRe(err, r"^Checking branch at '.*'\.\n"
 
54
                                   r"checked branch.*\n$")
 
55
 
 
56
    def test_check_repository(self):
 
57
        tree = self.make_branch_and_tree('.')
 
58
        tree.commit('foo')
 
59
        out, err = self.run_bzr('check --repo')
 
60
        self.assertContainsRe(err, r"^Checking repository at '.*'\.\n"
 
61
                                   r"checked repository.*\n"
 
62
                                   r"     1 revisions\n"
 
63
                                   r"     [01] file-ids\n"
 
64
                                   r"     0 unique file texts\n"
 
65
                                   r"     0 repeated file texts\n"
 
66
                                   r"     0 unreferenced text versions$")
 
67
 
 
68
    def test_check_tree(self):
 
69
        tree = self.make_branch_and_tree('.')
 
70
        tree.commit('foo')
 
71
        out, err = self.run_bzr('check --tree')
 
72
        self.assertContainsRe(err, r"^Checking working tree at '.*'\.\n$")
 
73
 
 
74
    def test_partial_check(self):
 
75
        tree = self.make_branch_and_tree('.')
 
76
        tree.commit('foo')
 
77
        out, err = self.run_bzr('check --tree --branch')
 
78
        self.assertContainsRe(err, r"^Checking working tree at '.*'\.\n"
 
79
                                   r"Checking branch at '.*'\.\n"
 
80
                                   r"checked branch.*\n$")
 
81
 
 
82
    def test_check_missing_tree(self):
 
83
        branch = self.make_branch('.')
 
84
        out, err = self.run_bzr('check --tree')
 
85
        self.assertEqual(err, "No working tree found at specified location.\n")
 
86
 
 
87
    def test_check_missing_partial(self):
 
88
        branch = self.make_branch('.')
 
89
        out, err = self.run_bzr('check --tree --branch')
 
90
        self.assertContainsRe(err,
 
91
            r"^No working tree found at specified location\.\n"
 
92
            r"Checking branch at '.*'\.\n"
 
93
            r"checked branch.*\n$")
 
94
 
 
95
    def test_check_missing_branch_in_shared_repo(self):
 
96
        self.make_repository('shared', shared=True)
 
97
        out, err = self.run_bzr('check --branch shared')
 
98
        self.assertEqual(err, "No branch found at specified location.\n")
 
99
 
 
100
 
 
101
class ChrootedCheckTests(ChrootedTestCase):
 
102
 
 
103
    def test_check_missing_branch(self):
 
104
        out, err = self.run_bzr(
 
105
            'check --branch %s' % self.get_readonly_url(''))
 
106
        self.assertEqual(err, "No branch found at specified location.\n")
 
107
 
 
108
    def test_check_missing_repository(self):
 
109
        out, err = self.run_bzr('check --repo %s' % self.get_readonly_url(''))
 
110
        self.assertEqual(err, "No repository found at specified location.\n")
 
111
 
 
112
    def test_check_missing_everything(self):
 
113
        out, err = self.run_bzr('check %s' % self.get_readonly_url(''))
 
114
        self.assertEqual(err, "No working tree found at specified location.\n"
 
115
                              "No branch found at specified location.\n"
 
116
                              "No repository found at specified location.\n")