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
17
"""Blackbox tests for version_info"""
21
from bzrlib.tests import TestCaseWithTransport
24
class TestVersionInfo(TestCaseWithTransport):
26
def test_invalid_format(self):
27
self.run_bzr('version-info', '--format', 'quijibo', retcode=3)
29
def create_branch(self):
30
wt = self.make_branch_and_tree('branch')
32
self.build_tree(['branch/a'])
34
wt.commit('adding a', rev_id='r1')
36
self.build_tree(['branch/b'])
38
wt.commit('adding b', rev_id='r2')
40
self.revisions = wt.branch.revision_history()
45
txt = self.run_bzr('version-info', 'branch')[0]
46
self.assertContainsRe(txt, 'date:')
47
self.assertContainsRe(txt, 'build-date:')
48
self.assertContainsRe(txt, 'revno: 2')
49
self.assertContainsRe(txt, 'revision-id: ' + self.revisions[-1])
52
"""'--all' includes clean, revision history, and file revisions"""
54
txt = self.run_bzr('version-info', 'branch',
56
self.assertContainsRe(txt, 'date:')
57
self.assertContainsRe(txt, 'revno: 2')
58
self.assertContainsRe(txt, 'revision-id: ' + self.revisions[-1])
59
self.assertContainsRe(txt, 'clean: True')
60
self.assertContainsRe(txt, 'revisions:')
61
for rev_id in self.revisions:
62
self.assertContainsRe(txt, 'id: ' + rev_id)
63
self.assertContainsRe(txt, 'message: adding a')
64
self.assertContainsRe(txt, 'message: adding b')
65
self.assertContainsRe(txt, 'file-revisions:')
66
self.assertContainsRe(txt, 'path: a')
67
self.assertContainsRe(txt, 'path: b')
70
"""Test that --check-clean includes the right info"""
73
txt = self.run_bzr('version-info', 'branch',
75
self.assertContainsRe(txt, 'clean: True')
77
self.build_tree_contents([('branch/c', 'now unclean\n')])
78
txt = self.run_bzr('version-info', 'branch',
80
self.assertContainsRe(txt, 'clean: False')
82
txt = self.run_bzr('version-info', 'branch',
83
'--check-clean', '--include-file-revisions')[0]
84
self.assertContainsRe(txt, 'revision: unversioned')
88
def test_no_branch(self):
89
"""Test that bzr defaults to the local working directory"""
92
txt1 = self.run_bzr('version-info', 'branch')[0]
95
txt2 = self.run_bzr('version-info')[0]
96
self.assertEqual(txt1, txt2)
99
"""Test that we can pass --format=rio"""
102
txt = self.run_bzr('version-info', 'branch')[0]
103
txt1 = self.run_bzr('version-info', '--format', 'rio', 'branch')[0]
104
txt2 = self.run_bzr('version-info', '--format=rio', 'branch')[0]
105
self.assertEqual(txt, txt1)
106
self.assertEqual(txt, txt2)
108
def test_python(self):
109
"""Test that we can do --format=python"""
112
txt = self.run_bzr('version-info', '--format', 'python', 'branch')[0]
114
self.assertContainsRe(txt, 'version_info = {')