1
# Copyright (C) 2005 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 bzr.
21
These check that it behaves properly when it's invoked through the regular
22
command-line interface. This doesn't actually run a new interpreter but
23
rather starts again from the run_bzr function.
29
from bzrlib.tests import TestCaseWithTransport
32
class TestAnnotate(TestCaseWithTransport):
35
super(TestAnnotate, self).setUp()
36
wt = self.make_branch_and_tree('.')
38
self.build_tree_contents([('hello.txt', 'my helicopter\n'),
39
('nomail.txt', 'nomail\n')])
41
self.revision_id_1 = wt.commit('add hello',
42
committer='test@user', timestamp=1165960000.00)
43
wt.add(['nomail.txt'])
44
self.revision_id_2 = wt.commit('add nomail',
45
committer='no mail', timestamp=1165970000.00)
46
self.build_tree_contents([('hello.txt', 'my helicopter\n'
47
'your helicopter\n')])
48
self.revision_id_3 = wt.commit('mod hello',
49
committer='user@test', timestamp=1166040000.00)
50
self.build_tree_contents([('hello.txt', 'my helicopter\n'
55
self.revision_id_4 = wt.commit('mod hello',
56
committer='user@test', timestamp=1166050000.00)
58
def test_help_annotate(self):
59
"""Annotate command exists"""
60
out, err = self.run_bzr('--no-plugins', 'annotate', '--help')
62
def test_annotate_cmd(self):
63
out, err = self.run_bzr('annotate', 'hello.txt')
64
self.assertEqual('', err)
65
self.assertEqualDiff('''\
66
1 test@us | my helicopter
67
3 user@te | your helicopter
72
def test_annotate_cmd_full(self):
73
out, err = self.run_bzr('annotate', 'hello.txt', '--all')
74
self.assertEqual('', err)
75
self.assertEqualDiff('''\
76
1 test@us | my helicopter
77
3 user@te | your helicopter
79
4 user@te | our helicopters
82
def test_annotate_cmd_long(self):
83
out, err = self.run_bzr('annotate', 'hello.txt', '--long')
84
self.assertEqual('', err)
85
self.assertEqualDiff('''\
86
1 test@user 20061212 | my helicopter
87
3 user@test 20061213 | your helicopter
88
4 user@test 20061213 | all of
92
def test_annotate_cmd_show_ids(self):
93
out, err = self.run_bzr('annotate', 'hello.txt', '--show-ids')
94
max_len = max([len(self.revision_id_1),
95
len(self.revision_id_3),
96
len(self.revision_id_4)])
97
self.assertEqual('', err)
98
self.assertEqualDiff('''\
100
%*s | your helicopter
102
%*s | our helicopters
103
''' % (max_len, self.revision_id_1,
104
max_len, self.revision_id_3,
105
max_len, self.revision_id_4,
110
def test_no_mail(self):
111
out, err = self.run_bzr('annotate', 'nomail.txt')
112
self.assertEqual('', err)
113
self.assertEqualDiff('''\
117
def test_annotate_cmd_revision(self):
118
out, err = self.run_bzr('annotate', 'hello.txt', '-r1')
119
self.assertEqual('', err)
120
self.assertEqualDiff('''\
121
1 test@us | my helicopter
124
def test_annotate_cmd_revision3(self):
125
out, err = self.run_bzr('annotate', 'hello.txt', '-r3')
126
self.assertEqual('', err)
127
self.assertEqualDiff('''\
128
1 test@us | my helicopter
129
3 user@te | your helicopter
132
def test_annotate_cmd_unknown_revision(self):
133
out, err = self.run_bzr('annotate', 'hello.txt', '-r', '10',
135
self.assertEqual('', out)
136
self.assertContainsRe(err, 'Requested revision: \'10\' does not exist')
138
def test_annotate_cmd_two_revisions(self):
139
out, err = self.run_bzr('annotate', 'hello.txt', '-r1..2',
141
self.assertEqual('', out)
142
self.assertEqual('bzr: ERROR: bzr annotate --revision takes'
143
' exactly 1 argument\n',
146
def test_annotate_empty_file(self):
147
tree = self.make_branch_and_tree('tree')
148
self.build_tree_contents([('tree/empty', '')])
150
tree.commit('add empty file')
153
out, err = self.run_bzr('annotate', 'empty')
154
self.assertEqual('', out)