1
# Copyright (C) 2005, 2006 Canonical Ltd
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
"""Black-box tests for default log_formats/log_formatters
21
from bzrlib.branch import Branch
22
from bzrlib.tests import TestCaseInTempDir
23
from bzrlib.config import (ensure_config_dir_exists, config_filename)
26
class TestLogFormats(TestCaseInTempDir):
28
def bzr(self, *args, **kwargs):
29
return self.run_bzr(*args, **kwargs)[0]
31
def test_log_default_format(self):
35
open('a', 'wb').write('foo\n')
38
self.bzr('commit -m 1')
39
open('a', 'wb').write('baz\n')
41
self.bzr('commit -m 2')
43
# only the lines formatter is this short
44
self.assertEquals(3, len(self.bzr('log').split('\n')))
46
def test_log_format_arg(self):
48
open('a', 'wb').write('foo\n')
51
self.bzr('commit -m 1')
52
open('a', 'wb').write('baz\n')
54
self.bzr('commit -m 2')
56
# only the lines formatter is this short
57
self.assertEquals(7, len(self.bzr('log --log-format short').split('\n')))
59
def test_missing_default_format(self):
66
open('a', 'wb').write('foo\n')
68
self.bzr('commit -m 1')
71
self.bzr('branch a b')
74
open('a', 'wb').write('bar\n')
75
self.bzr('commit -m 2')
77
open('a', 'wb').write('baz\n')
78
self.bzr('commit -m 3')
82
self.assertEquals(5, len(self.bzr('missing', retcode=1).split('\n')))
86
def test_missing_format_arg(self):
93
open('a', 'wb').write('foo\n')
95
self.bzr('commit -m 1')
98
self.bzr('branch a b')
101
open('a', 'wb').write('bar\n')
102
self.bzr('commit -m 2')
104
open('a', 'wb').write('baz\n')
105
self.bzr('commit -m 3')
109
self.assertEquals(9, len(self.bzr('missing --log-format short',
110
retcode=1).split('\n')))
115
def setup_config(self):
116
if os.path.isfile(config_filename()):
117
# Something is wrong in environment,
118
# we risk overwriting users config
119
self.assert_(config_filename() + "exists, abort")
121
ensure_config_dir_exists()
122
CONFIG=("[DEFAULT]\n"
123
"email=Joe Foo <joe@foo.com>\n"
126
open(config_filename(),'wb').write(CONFIG)