5557.1.15
by John Arbash Meinel
Merge bzr.dev 5597 to resolve NEWS, aka bzr-2.3.txt |
1 |
# Copyright (C) 2005-2011 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 |
"""Tests for version_info"""
|
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
18 |
|
2022.1.1
by John Arbash Meinel
[merge] version-info plugin, and cleanup for layout in bzr |
19 |
from cStringIO import StringIO |
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 |
import imp |
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
21 |
import os |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
22 |
import sys |
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
23 |
|
3138.1.1
by John Arbash Meinel
Fix bug #175886: version_info deprecated functions should be tested to still work. |
24 |
from bzrlib import ( |
3207.1.1
by Lukáš Lalinský
Raise a proper error when 'version-info --custom' is used without a template |
25 |
errors, |
4985.1.5
by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity |
26 |
registry, |
3138.1.1
by John Arbash Meinel
Fix bug #175886: version_info deprecated functions should be tested to still work. |
27 |
tests, |
28 |
version_info_formats, |
|
29 |
)
|
|
2022.1.3
by John Arbash Meinel
Remove unused imports |
30 |
from bzrlib.tests import TestCaseWithTransport |
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
31 |
from bzrlib.rio import read_stanzas |
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
32 |
|
2948.4.1
by Lukáš Lalinský
Custom template-based version info formatter. |
33 |
from bzrlib.version_info_formats.format_custom import CustomVersionInfoBuilder |
2022.1.1
by John Arbash Meinel
[merge] version-info plugin, and cleanup for layout in bzr |
34 |
from bzrlib.version_info_formats.format_rio import RioVersionInfoBuilder |
35 |
from bzrlib.version_info_formats.format_python import PythonVersionInfoBuilder |
|
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
36 |
|
37 |
||
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
38 |
class TestVersionInfo(TestCaseWithTransport): |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
39 |
|
40 |
def create_branch(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. |
41 |
wt = self.make_branch_and_tree('branch') |
0.8.23
by John Arbash Meinel
whitespace and formatting cleanups. |
42 |
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
43 |
self.build_tree(['branch/a']) |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
44 |
wt.add('a') |
45 |
wt.commit('a', rev_id='r1') |
|
46 |
||
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
47 |
self.build_tree(['branch/b']) |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
48 |
wt.add('b') |
49 |
wt.commit('b', rev_id='r2') |
|
50 |
||
2022.1.4
by John Arbash Meinel
test feedback from Robert. |
51 |
self.build_tree_contents([('branch/a', 'new contents\n')]) |
2030.1.2
by John Arbash Meinel
Change the version-info --format=rio to support unicode messages |
52 |
wt.commit(u'\xe52', rev_id='r3') |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
53 |
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
54 |
return wt |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
55 |
|
5967.11.4
by Benoît Pierre
Rename tests helper "create_tree_on_dotted_revno" to "create_tree_with_dotted_revno". |
56 |
def create_tree_with_dotted_revno(self): |
5967.11.1
by Benoît Pierre
Update version-info tests. |
57 |
wt = self.make_branch_and_tree('branch') |
58 |
self.build_tree(['branch/a']) |
|
59 |
wt.add('a') |
|
60 |
wt.commit('a', rev_id='r1') |
|
61 |
||
62 |
other = wt.bzrdir.sprout('other').open_workingtree() |
|
63 |
self.build_tree(['other/b.a']) |
|
64 |
other.add(['b.a']) |
|
65 |
other.commit('b.a', rev_id='o2') |
|
66 |
||
67 |
os.chdir('branch') |
|
68 |
self.run_bzr('merge ../other') |
|
69 |
wt.commit('merge', rev_id='merge') |
|
70 |
||
71 |
wt.update(revision='o2') |
|
72 |
||
73 |
return wt |
|
74 |
||
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
75 |
def test_rio_null(self): |
76 |
wt = self.make_branch_and_tree('branch') |
|
77 |
||
78 |
sio = StringIO() |
|
79 |
builder = RioVersionInfoBuilder(wt.branch, working_tree=wt) |
|
80 |
builder.generate(sio) |
|
81 |
val = sio.getvalue() |
|
82 |
self.assertContainsRe(val, 'build-date:') |
|
83 |
self.assertContainsRe(val, 'revno: 0') |
|
84 |
||
5967.11.1
by Benoît Pierre
Update version-info tests. |
85 |
def test_rio_dotted_revno(self): |
5967.11.4
by Benoît Pierre
Rename tests helper "create_tree_on_dotted_revno" to "create_tree_with_dotted_revno". |
86 |
wt = self.create_tree_with_dotted_revno() |
5967.11.1
by Benoît Pierre
Update version-info tests. |
87 |
|
88 |
sio = StringIO() |
|
89 |
builder = RioVersionInfoBuilder(wt.branch, working_tree=wt) |
|
90 |
builder.generate(sio) |
|
91 |
val = sio.getvalue() |
|
92 |
self.assertContainsRe(val, 'revno: 1.1.1') |
|
93 |
||
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
94 |
def test_rio_version_text(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. |
95 |
wt = self.create_branch() |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
96 |
|
97 |
def regen(**kwargs): |
|
98 |
sio = StringIO() |
|
0.8.23
by John Arbash Meinel
whitespace and formatting cleanups. |
99 |
builder = RioVersionInfoBuilder(wt.branch, working_tree=wt, |
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
100 |
**kwargs) |
101 |
builder.generate(sio) |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
102 |
val = sio.getvalue() |
103 |
return val |
|
104 |
||
105 |
val = regen() |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
106 |
self.assertContainsRe(val, 'build-date:') |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
107 |
self.assertContainsRe(val, 'date:') |
108 |
self.assertContainsRe(val, 'revno: 3') |
|
0.8.16
by John Arbash Meinel
Using revision-id for rio, and revision_id for python |
109 |
self.assertContainsRe(val, 'revision-id: r3') |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
110 |
|
111 |
val = regen(check_for_clean=True) |
|
112 |
self.assertContainsRe(val, 'clean: True') |
|
113 |
||
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
114 |
self.build_tree(['branch/c']) |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
115 |
val = regen(check_for_clean=True) |
116 |
self.assertContainsRe(val, 'clean: False') |
|
117 |
os.remove('branch/c') |
|
118 |
||
119 |
val = regen(include_revision_history=True) |
|
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
120 |
self.assertContainsRe(val, 'id: r1') |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
121 |
self.assertContainsRe(val, 'message: a') |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
122 |
self.assertContainsRe(val, 'id: r2') |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
123 |
self.assertContainsRe(val, 'message: b') |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
124 |
self.assertContainsRe(val, 'id: r3') |
2030.1.2
by John Arbash Meinel
Change the version-info --format=rio to support unicode messages |
125 |
self.assertContainsRe(val, 'message: \xc3\xa52') # utf8 encoding '\xe5' |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
126 |
|
4216.4.1
by Jelmer Vernooij
Allow hooks to add new entries to version-info. |
127 |
def test_rio_version_hook(self): |
128 |
def update_stanza(rev, stanza): |
|
129 |
stanza.add('bla', 'bloe') |
|
130 |
RioVersionInfoBuilder.hooks.install_named_hook( |
|
131 |
'revision', update_stanza, None) |
|
132 |
wt = self.create_branch() |
|
133 |
||
134 |
def regen(**kwargs): |
|
135 |
sio = StringIO() |
|
136 |
builder = RioVersionInfoBuilder(wt.branch, working_tree=wt, |
|
137 |
**kwargs) |
|
138 |
builder.generate(sio) |
|
139 |
sio.seek(0) |
|
140 |
stanzas = list(read_stanzas(sio)) |
|
141 |
self.assertEqual(1, len(stanzas)) |
|
142 |
return stanzas[0] |
|
143 |
||
144 |
stanza = regen() |
|
145 |
self.assertEqual(['bloe'], stanza.get_all('bla')) |
|
146 |
||
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
147 |
def test_rio_version(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. |
148 |
wt = self.create_branch() |
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
149 |
|
150 |
def regen(**kwargs): |
|
151 |
sio = StringIO() |
|
0.8.23
by John Arbash Meinel
whitespace and formatting cleanups. |
152 |
builder = RioVersionInfoBuilder(wt.branch, working_tree=wt, |
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
153 |
**kwargs) |
154 |
builder.generate(sio) |
|
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
155 |
sio.seek(0) |
156 |
stanzas = list(read_stanzas(sio)) |
|
157 |
self.assertEqual(1, len(stanzas)) |
|
158 |
return stanzas[0] |
|
159 |
||
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
160 |
def get_one_stanza(stanza, key): |
2022.1.1
by John Arbash Meinel
[merge] version-info plugin, and cleanup for layout in bzr |
161 |
new_stanzas = list(read_stanzas( |
162 |
StringIO(stanza[key].encode('utf8')))) |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
163 |
self.assertEqual(1, len(new_stanzas)) |
164 |
return new_stanzas[0] |
|
165 |
||
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
166 |
stanza = regen() |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
167 |
self.assertTrue('date' in stanza) |
168 |
self.assertTrue('build-date' in stanza) |
|
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
169 |
self.assertEqual(['3'], stanza.get_all('revno')) |
0.8.16
by John Arbash Meinel
Using revision-id for rio, and revision_id for python |
170 |
self.assertEqual(['r3'], stanza.get_all('revision-id')) |
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
171 |
|
172 |
stanza = regen(check_for_clean=True) |
|
173 |
self.assertEqual(['True'], stanza.get_all('clean')) |
|
174 |
||
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
175 |
self.build_tree(['branch/c']) |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
176 |
stanza = regen(check_for_clean=True, include_file_revisions=True) |
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
177 |
self.assertEqual(['False'], stanza.get_all('clean')) |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
178 |
|
4599.4.2
by Robert Collins
Update test_version_info for rich root test data. |
179 |
# This assumes it's being run against a tree that does not update the
|
180 |
# root revision on every commit.
|
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
181 |
file_rev_stanza = get_one_stanza(stanza, 'file-revisions') |
1731.1.50
by Aaron Bentley
Merge bzr.dev |
182 |
self.assertEqual(['', 'a', 'b', 'c'], file_rev_stanza.get_all('path')) |
4599.4.2
by Robert Collins
Update test_version_info for rich root test data. |
183 |
self.assertEqual(['r1', 'r3', 'r2', 'unversioned'], |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
184 |
file_rev_stanza.get_all('revision')) |
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
185 |
os.remove('branch/c') |
186 |
||
187 |
stanza = regen(include_revision_history=True) |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
188 |
revision_stanza = get_one_stanza(stanza, 'revisions') |
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
189 |
self.assertEqual(['r1', 'r2', 'r3'], revision_stanza.get_all('id')) |
2030.1.2
by John Arbash Meinel
Change the version-info --format=rio to support unicode messages |
190 |
self.assertEqual(['a', 'b', u'\xe52'], revision_stanza.get_all('message')) |
0.8.15
by John Arbash Meinel
Including the date stamp for all revisions. |
191 |
self.assertEqual(3, len(revision_stanza.get_all('date'))) |
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
192 |
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
193 |
# a was modified, so it should show up modified again
|
194 |
self.build_tree(['branch/a', 'branch/c']) |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
195 |
wt.add('c') |
196 |
wt.rename_one('b', 'd') |
|
197 |
stanza = regen(check_for_clean=True, include_file_revisions=True) |
|
198 |
file_rev_stanza = get_one_stanza(stanza, 'file-revisions') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
199 |
self.assertEqual(['', 'a', 'b', 'c', 'd'], |
1731.1.50
by Aaron Bentley
Merge bzr.dev |
200 |
file_rev_stanza.get_all('path')) |
4599.4.2
by Robert Collins
Update test_version_info for rich root test data. |
201 |
self.assertEqual(['r1', 'modified', 'renamed to d', 'new', |
1731.1.50
by Aaron Bentley
Merge bzr.dev |
202 |
'renamed from b'], |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
203 |
file_rev_stanza.get_all('revision')) |
204 |
||
205 |
wt.commit('modified', rev_id='r4') |
|
206 |
wt.remove(['c', 'd']) |
|
207 |
os.remove('branch/d') |
|
208 |
stanza = regen(check_for_clean=True, include_file_revisions=True) |
|
209 |
file_rev_stanza = get_one_stanza(stanza, 'file-revisions') |
|
1731.1.50
by Aaron Bentley
Merge bzr.dev |
210 |
self.assertEqual(['', 'a', 'c', 'd'], file_rev_stanza.get_all('path')) |
4599.4.2
by Robert Collins
Update test_version_info for rich root test data. |
211 |
self.assertEqual(['r1', 'r4', 'unversioned', 'removed'], |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
212 |
file_rev_stanza.get_all('revision')) |
213 |
||
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
214 |
def test_python_null(self): |
215 |
wt = self.make_branch_and_tree('branch') |
|
216 |
||
217 |
sio = StringIO() |
|
218 |
builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt) |
|
219 |
builder.generate(sio) |
|
220 |
val = sio.getvalue() |
|
221 |
self.assertContainsRe(val, "'revision_id': None") |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
222 |
self.assertContainsRe(val, "'revno': '0'") |
5598.1.1
by Soren Hansen
Fix PEP-8 violation in PythonVersionInfoBuilder's output |
223 |
self.assertNotContainsString(val, '\n\n\n\n') |
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
224 |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
225 |
def test_python_dotted_revno(self): |
5967.11.4
by Benoît Pierre
Rename tests helper "create_tree_on_dotted_revno" to "create_tree_with_dotted_revno". |
226 |
wt = self.create_tree_with_dotted_revno() |
5967.11.1
by Benoît Pierre
Update version-info tests. |
227 |
|
228 |
sio = StringIO() |
|
229 |
builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt) |
|
230 |
builder.generate(sio) |
|
231 |
val = sio.getvalue() |
|
232 |
self.assertContainsRe(val, "'revno': '1.1.1'") |
|
233 |
||
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
234 |
def test_python_version(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. |
235 |
wt = self.create_branch() |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
236 |
|
237 |
def regen(**kwargs): |
|
2022.1.4
by John Arbash Meinel
test feedback from Robert. |
238 |
"""Create a test module, import and return it"""
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
239 |
outf = open('test_version_information.py', 'wb') |
2022.1.4
by John Arbash Meinel
test feedback from Robert. |
240 |
try: |
241 |
builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt, |
|
242 |
**kwargs) |
|
243 |
builder.generate(outf) |
|
244 |
finally: |
|
245 |
outf.close() |
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
246 |
module_info = imp.find_module('test_version_information', |
247 |
[os.getcwdu()]) |
|
248 |
tvi = imp.load_module('tvi', *module_info) |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
249 |
# Make sure the module isn't cached
|
250 |
sys.modules.pop('tvi', None) |
|
251 |
sys.modules.pop('test_version_information', None) |
|
252 |
# Delete the compiled versions, because we are generating
|
|
253 |
# a new file fast enough that python doesn't detect it
|
|
254 |
# needs to recompile, and using sleep() just makes the
|
|
255 |
# test slow
|
|
256 |
if os.path.exists('test_version_information.pyc'): |
|
257 |
os.remove('test_version_information.pyc') |
|
258 |
if os.path.exists('test_version_information.pyo'): |
|
259 |
os.remove('test_version_information.pyo') |
|
260 |
return tvi |
|
261 |
||
262 |
tvi = regen() |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
263 |
self.assertEqual('3', tvi.version_info['revno']) |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
264 |
self.assertEqual('r3', tvi.version_info['revision_id']) |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
265 |
self.assertTrue(tvi.version_info.has_key('date')) |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
266 |
self.assertEqual(None, tvi.version_info['clean']) |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
267 |
|
268 |
tvi = regen(check_for_clean=True) |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
269 |
self.assertEqual(True, tvi.version_info['clean']) |
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
270 |
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
271 |
self.build_tree(['branch/c']) |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
272 |
tvi = regen(check_for_clean=True, include_file_revisions=True) |
273 |
self.assertEqual(False, tvi.version_info['clean']) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
274 |
self.assertEqual(['', 'a', 'b', 'c'], |
1731.1.50
by Aaron Bentley
Merge bzr.dev |
275 |
sorted(tvi.file_revisions.keys())) |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
276 |
self.assertEqual('r3', tvi.file_revisions['a']) |
277 |
self.assertEqual('r2', tvi.file_revisions['b']) |
|
278 |
self.assertEqual('unversioned', tvi.file_revisions['c']) |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
279 |
os.remove('branch/c') |
280 |
||
281 |
tvi = regen(include_revision_history=True) |
|
0.8.15
by John Arbash Meinel
Including the date stamp for all revisions. |
282 |
|
0.8.23
by John Arbash Meinel
whitespace and formatting cleanups. |
283 |
rev_info = [(rev, message) for rev, message, timestamp, timezone |
284 |
in tvi.revisions] |
|
2030.1.2
by John Arbash Meinel
Change the version-info --format=rio to support unicode messages |
285 |
self.assertEqual([('r1', 'a'), ('r2', 'b'), ('r3', u'\xe52')], rev_info) |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
286 |
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
287 |
# a was modified, so it should show up modified again
|
288 |
self.build_tree(['branch/a', 'branch/c']) |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
289 |
wt.add('c') |
290 |
wt.rename_one('b', 'd') |
|
291 |
tvi = regen(check_for_clean=True, include_file_revisions=True) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
292 |
self.assertEqual(['', 'a', 'b', 'c', 'd'], |
1731.1.50
by Aaron Bentley
Merge bzr.dev |
293 |
sorted(tvi.file_revisions.keys())) |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
294 |
self.assertEqual('modified', tvi.file_revisions['a']) |
295 |
self.assertEqual('renamed to d', tvi.file_revisions['b']) |
|
296 |
self.assertEqual('new', tvi.file_revisions['c']) |
|
297 |
self.assertEqual('renamed from b', tvi.file_revisions['d']) |
|
298 |
||
299 |
wt.commit('modified', rev_id='r4') |
|
300 |
wt.remove(['c', 'd']) |
|
301 |
os.remove('branch/d') |
|
302 |
tvi = regen(check_for_clean=True, include_file_revisions=True) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
303 |
self.assertEqual(['', 'a', 'c', 'd'], |
1731.1.50
by Aaron Bentley
Merge bzr.dev |
304 |
sorted(tvi.file_revisions.keys())) |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
305 |
self.assertEqual('r4', tvi.file_revisions['a']) |
306 |
self.assertEqual('unversioned', tvi.file_revisions['c']) |
|
307 |
self.assertEqual('removed', tvi.file_revisions['d']) |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
308 |
|
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
309 |
def test_custom_null(self): |
310 |
sio = StringIO() |
|
311 |
wt = self.make_branch_and_tree('branch') |
|
312 |
builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, |
|
313 |
template='revno: {revno}') |
|
314 |
builder.generate(sio) |
|
315 |
self.assertEquals("revno: 0", sio.getvalue()) |
|
316 |
||
317 |
builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, |
|
318 |
template='{revno} revid: {revision_id}') |
|
319 |
# revision_id is not available yet
|
|
320 |
self.assertRaises(errors.MissingTemplateVariable, |
|
321 |
builder.generate, sio) |
|
322 |
||
5967.11.1
by Benoît Pierre
Update version-info tests. |
323 |
def test_custom_dotted_revno(self): |
324 |
sio = StringIO() |
|
5967.11.4
by Benoît Pierre
Rename tests helper "create_tree_on_dotted_revno" to "create_tree_with_dotted_revno". |
325 |
wt = self.create_tree_with_dotted_revno() |
5967.11.1
by Benoît Pierre
Update version-info tests. |
326 |
builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, |
327 |
template='{revno} revid: {revision_id}') |
|
328 |
builder.generate(sio) |
|
329 |
self.assertEquals("1.1.1 revid: o2", sio.getvalue()) |
|
330 |
||
2948.4.1
by Lukáš Lalinský
Custom template-based version info formatter. |
331 |
def test_custom_version_text(self): |
332 |
wt = self.create_branch() |
|
333 |
||
334 |
def regen(tpl, **kwargs): |
|
335 |
sio = StringIO() |
|
336 |
builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, |
|
337 |
template=tpl, **kwargs) |
|
338 |
builder.generate(sio) |
|
339 |
val = sio.getvalue() |
|
340 |
return val |
|
341 |
||
342 |
val = regen('build-date: "{build_date}"\ndate: "{date}"') |
|
343 |
self.assertContainsRe(val, 'build-date: "[0-9-+: ]+"') |
|
344 |
self.assertContainsRe(val, 'date: "[0-9-+: ]+"') |
|
345 |
||
346 |
val = regen('revno: {revno}') |
|
347 |
self.assertEqual(val, 'revno: 3') |
|
348 |
||
349 |
val = regen('revision-id: {revision_id}') |
|
350 |
self.assertEqual(val, 'revision-id: r3') |
|
351 |
||
352 |
val = regen('clean: {clean}', check_for_clean=True) |
|
353 |
self.assertEqual(val, 'clean: 1') |
|
354 |
||
355 |
self.build_tree(['branch/c']) |
|
356 |
val = regen('clean: {clean}', check_for_clean=True) |
|
357 |
self.assertEqual(val, 'clean: 0') |
|
358 |
os.remove('branch/c') |
|
3138.1.1
by John Arbash Meinel
Fix bug #175886: version_info deprecated functions should be tested to still work. |
359 |
|
3207.1.1
by Lukáš Lalinský
Raise a proper error when 'version-info --custom' is used without a template |
360 |
def test_custom_without_template(self): |
361 |
builder = CustomVersionInfoBuilder(None) |
|
362 |
sio = StringIO() |
|
363 |
self.assertRaises(errors.NoTemplate, builder.generate, sio) |
|
364 |
||
3138.1.1
by John Arbash Meinel
Fix bug #175886: version_info deprecated functions should be tested to still work. |
365 |
|
366 |
class TestBuilder(version_info_formats.VersionInfoBuilder): |
|
367 |
pass
|
|
368 |
||
369 |
||
370 |
class TestVersionInfoFormatRegistry(tests.TestCase): |
|
371 |
||
372 |
def setUp(self): |
|
373 |
super(TestVersionInfoFormatRegistry, self).setUp() |
|
4985.1.5
by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity |
374 |
self.overrideAttr(version_info_formats, |
375 |
'format_registry', registry.Registry()) |
|
3138.1.1
by John Arbash Meinel
Fix bug #175886: version_info deprecated functions should be tested to still work. |
376 |
|
377 |
def test_register_remove(self): |
|
378 |
registry = version_info_formats.format_registry |
|
379 |
registry.register('testbuilder', |
|
380 |
TestBuilder, 'a simple test builder') |
|
381 |
self.assertIs(TestBuilder, registry.get('testbuilder')) |
|
382 |
self.assertEqual('a simple test builder', |
|
383 |
registry.get_help('testbuilder')) |
|
384 |
registry.remove('testbuilder') |
|
385 |
self.assertRaises(KeyError, registry.get, 'testbuilder') |