5452.4.3
by John Arbash Meinel
Merge bzr.dev to resolve bzr-2.3.txt (aka NEWS) |
1 |
# Copyright (C) 2005-2010 Canonical Ltd
|
0.8.21
by John Arbash Meinel
Splitting up the version info code into a lazy factory style. |
2 |
#
|
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
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.
|
|
0.8.21
by John Arbash Meinel
Splitting up the version info code into a lazy factory style. |
7 |
#
|
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
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.
|
|
0.8.21
by John Arbash Meinel
Splitting up the version info code into a lazy factory style. |
12 |
#
|
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
16 |
|
0.8.21
by John Arbash Meinel
Splitting up the version info code into a lazy factory style. |
17 |
"""Blackbox tests for version_info"""
|
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
18 |
|
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
19 |
import os |
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
20 |
|
2022.1.3
by John Arbash Meinel
Remove unused imports |
21 |
from bzrlib.tests import TestCaseWithTransport |
6234.3.1
by Lawrence Mitchell
Introduce failing test for version-info templates without {clean} |
22 |
from bzrlib.version_info_formats import VersionInfoBuilder |
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
23 |
|
6406.1.3
by Jelmer Vernooij
Fix version_info tree. |
24 |
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
25 |
class TestVersionInfo(TestCaseWithTransport): |
0.8.2
by John Arbash Meinel
Have working rio output |
26 |
|
27 |
def test_invalid_format(self): |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
28 |
self.run_bzr('version-info --format quijibo', retcode=3) |
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
29 |
|
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
30 |
def create_tree(self): |
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
31 |
wt = self.make_branch_and_tree('branch') |
0.8.23
by John Arbash Meinel
whitespace and formatting cleanups. |
32 |
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
33 |
self.build_tree(['branch/a']) |
34 |
wt.add('a') |
|
35 |
wt.commit('adding a', rev_id='r1') |
|
36 |
||
37 |
self.build_tree(['branch/b']) |
|
38 |
wt.add('b') |
|
39 |
wt.commit('adding b', rev_id='r2') |
|
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
40 |
return wt |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
41 |
|
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
42 |
def test_basic(self): |
6165.4.24
by Jelmer Vernooij
Avoid revision_history() |
43 |
wt = self.create_tree() |
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
44 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
45 |
txt = self.run_bzr('version-info branch')[0] |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
46 |
self.assertContainsRe(txt, 'date:') |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
47 |
self.assertContainsRe(txt, 'build-date:') |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
48 |
self.assertContainsRe(txt, 'revno: 2') |
6165.4.24
by Jelmer Vernooij
Avoid revision_history() |
49 |
self.assertContainsRe(txt, 'revision-id: ' + wt.branch.last_revision()) |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
50 |
|
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
51 |
def test_all(self): |
52 |
"""'--all' includes clean, revision history, and file revisions"""
|
|
6165.4.24
by Jelmer Vernooij
Avoid revision_history() |
53 |
wt = self.create_tree() |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
54 |
txt = self.run_bzr('version-info branch --all')[0] |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
55 |
self.assertContainsRe(txt, 'date:') |
56 |
self.assertContainsRe(txt, 'revno: 2') |
|
6165.4.24
by Jelmer Vernooij
Avoid revision_history() |
57 |
self.assertContainsRe(txt, 'revision-id: ' + wt.branch.last_revision()) |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
58 |
self.assertContainsRe(txt, 'clean: True') |
59 |
self.assertContainsRe(txt, 'revisions:') |
|
6165.4.24
by Jelmer Vernooij
Avoid revision_history() |
60 |
for rev_id in wt.branch.repository.all_revision_ids(): |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
61 |
self.assertContainsRe(txt, 'id: ' + rev_id) |
62 |
self.assertContainsRe(txt, 'message: adding a') |
|
63 |
self.assertContainsRe(txt, 'message: adding b') |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
64 |
self.assertContainsRe(txt, 'file-revisions:') |
65 |
self.assertContainsRe(txt, 'path: a') |
|
66 |
self.assertContainsRe(txt, 'path: b') |
|
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
67 |
|
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
68 |
def test_clean(self): |
69 |
"""Test that --check-clean includes the right info"""
|
|
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
70 |
self.create_tree() |
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
71 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
72 |
txt = self.run_bzr('version-info branch --check-clean')[0] |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
73 |
self.assertContainsRe(txt, 'clean: True') |
74 |
||
2022.1.4
by John Arbash Meinel
test feedback from Robert. |
75 |
self.build_tree_contents([('branch/c', 'now unclean\n')]) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
76 |
txt = self.run_bzr('version-info branch --check-clean')[0] |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
77 |
self.assertContainsRe(txt, 'clean: False') |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
78 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
79 |
txt = self.run_bzr('version-info branch --check-clean' |
80 |
' --include-file-revisions')[0] |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
81 |
self.assertContainsRe(txt, 'revision: unversioned') |
82 |
||
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
83 |
os.remove('branch/c') |
84 |
||
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
85 |
def test_no_working_tree(self): |
86 |
tree = self.create_tree() |
|
87 |
branch = self.make_branch('just_branch') |
|
88 |
branch.pull(tree.branch) |
|
89 |
||
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
90 |
txt = self.run_bzr('version-info just_branch')[0] |
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
91 |
self.assertStartsWith(txt, 'revision-id: r2\n') |
92 |
||
2030.1.3
by John Arbash Meinel
Change comparisons to ignore the build-date field |
93 |
def assertEqualNoBuildDate(self, text1, text2): |
94 |
"""Compare 2 texts, but ignore the build-date field.
|
|
95 |
||
96 |
build-date is the current timestamp, accurate to seconds. But the
|
|
97 |
clock is always ticking, and it may have ticked between the time
|
|
98 |
that text1 and text2 were generated.
|
|
99 |
"""
|
|
100 |
lines1 = text1.splitlines(True) |
|
101 |
lines2 = text2.splitlines(True) |
|
102 |
for line1, line2 in zip(lines1, lines2): |
|
103 |
if line1.startswith('build-date: '): |
|
104 |
self.assertStartsWith(line2, 'build-date: ') |
|
105 |
else: |
|
106 |
self.assertEqual(line1, line2) |
|
107 |
self.assertEqual(len(lines1), len(lines2)) |
|
108 |
||
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
109 |
def test_no_branch(self): |
110 |
"""Test that bzr defaults to the local working directory"""
|
|
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
111 |
self.create_tree() |
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
112 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
113 |
txt1 = self.run_bzr('version-info branch')[0] |
2022.1.6
by John Arbash Meinel
small cleanup, remove unused imports |
114 |
|
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
115 |
os.chdir('branch') |
2022.1.6
by John Arbash Meinel
small cleanup, remove unused imports |
116 |
txt2 = self.run_bzr('version-info')[0] |
2030.1.3
by John Arbash Meinel
Change comparisons to ignore the build-date field |
117 |
self.assertEqualNoBuildDate(txt1, txt2) |
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
118 |
|
119 |
def test_rio(self): |
|
120 |
"""Test that we can pass --format=rio"""
|
|
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
121 |
self.create_tree() |
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
122 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
123 |
txt = self.run_bzr('version-info branch')[0] |
124 |
txt1 = self.run_bzr('version-info --format rio branch')[0] |
|
125 |
txt2 = self.run_bzr('version-info --format=rio branch')[0] |
|
2030.1.3
by John Arbash Meinel
Change comparisons to ignore the build-date field |
126 |
self.assertEqualNoBuildDate(txt, txt1) |
127 |
self.assertEqualNoBuildDate(txt, txt2) |
|
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
128 |
|
129 |
def test_python(self): |
|
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
130 |
"""Test that we can do --format=python"""
|
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
131 |
self.create_tree() |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
132 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
133 |
txt = self.run_bzr('version-info --format python branch')[0] |
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
134 |
|
2022.1.6
by John Arbash Meinel
small cleanup, remove unused imports |
135 |
self.assertContainsRe(txt, 'version_info = {') |
3207.1.1
by Lukáš Lalinský
Raise a proper error when 'version-info --custom' is used without a template |
136 |
|
137 |
def test_custom_without_template(self): |
|
138 |
wt = self.make_branch_and_tree('branch') |
|
139 |
out, err = self.run_bzr('version-info --custom', retcode=3) |
|
140 |
self.assertContainsRe(err, r'ERROR: No template specified\.') |
|
3231.2.1
by James Westby
Make version-info --custom imply --all. |
141 |
|
142 |
def test_custom_implies_all(self): |
|
143 |
self.create_tree() |
|
144 |
out, err = self.run_bzr('version-info --custom --template=' |
|
145 |
'"{revno} {branch_nick} {clean}\n" branch') |
|
146 |
self.assertEqual("2 branch 1\n", out) |
|
147 |
self.assertEqual("", err) |
|
148 |
self.build_tree_contents([('branch/c', 'now unclean\n')]) |
|
149 |
out, err = self.run_bzr('version-info --custom --template=' |
|
150 |
'"{revno} {branch_nick} {clean}\n" branch') |
|
151 |
self.assertEqual("2 branch 0\n", out) |
|
152 |
self.assertEqual("", err) |
|
6234.3.1
by Lawrence Mitchell
Introduce failing test for version-info templates without {clean} |
153 |
|
154 |
def test_custom_no_clean_in_template(self): |
|
155 |
def should_not_be_called(self): |
|
156 |
raise AssertionError("Method on %r should not have been used" % (self,)) |
|
157 |
self.overrideAttr(VersionInfoBuilder, "_extract_file_revisions", |
|
158 |
should_not_be_called) |
|
159 |
self.create_tree() |
|
160 |
out, err = self.run_bzr('version-info --custom --template=r{revno} branch') |
|
161 |
self.assertEqual("r2", out) |
|
162 |
self.assertEqual("", err) |
|
163 |
||
5436.1.2
by Andrej A Antonov
adding test: blackbox.test_version_info.TestVersionInfo.test_non_ascii |
164 |
def test_non_ascii(self): |
165 |
"""Test that we can output non-ascii data"""
|
|
6406.1.3
by Jelmer Vernooij
Fix version_info tree. |
166 |
|
5436.1.2
by Andrej A Antonov
adding test: blackbox.test_version_info.TestVersionInfo.test_non_ascii |
167 |
commit_message = u'Non-ascii message with character not in latin-1: \u1234' |
6406.1.3
by Jelmer Vernooij
Fix version_info tree. |
168 |
|
5436.1.3
by Andrej A Antonov
tiny simplification (remove unnecessary) in test 'blackbox.test_version_info.TestVersionInfo.test_non_ascii' |
169 |
tree = self.make_branch_and_tree('.') |
5436.1.2
by Andrej A Antonov
adding test: blackbox.test_version_info.TestVersionInfo.test_non_ascii |
170 |
self.build_tree(['a_file']) |
171 |
tree.add('a_file') |
|
172 |
tree.commit(commit_message) |
|
173 |
out, err = self.run_bzr( |
|
174 |
['version-info', '--include-history'], encoding='latin-1') |
|
6406.1.3
by Jelmer Vernooij
Fix version_info tree. |
175 |
|
5436.1.2
by Andrej A Antonov
adding test: blackbox.test_version_info.TestVersionInfo.test_non_ascii |
176 |
self.assertContainsString(out, commit_message.encode('utf-8')) |
177 |
||
6196.1.1
by Jelmer Vernooij
Add --revision argument to 'bzr version-info'. |
178 |
def test_revision(self): |
179 |
tree = self.create_tree() |
|
180 |
branch = self.make_branch('just_branch') |
|
181 |
branch.pull(tree.branch) |
|
5436.1.2
by Andrej A Antonov
adding test: blackbox.test_version_info.TestVersionInfo.test_non_ascii |
182 |
|
6196.1.1
by Jelmer Vernooij
Add --revision argument to 'bzr version-info'. |
183 |
txt = self.run_bzr('version-info -r1 just_branch')[0] |
184 |
self.assertStartsWith(txt, 'revision-id: r1\n') |