bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2005-2012, 2016 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 |
|
19 |
import os |
|
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
20 |
import sys |
|
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
21 |
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
22 |
from .. import ( |
|
4985.1.5
by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity |
23 |
registry, |
|
3138.1.1
by John Arbash Meinel
Fix bug #175886: version_info deprecated functions should be tested to still work. |
24 |
tests, |
25 |
version_info_formats, |
|
26 |
)
|
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
27 |
from ..sixish import ( |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
28 |
BytesIO, |
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
29 |
StringIO, |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
30 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
31 |
from . import TestCaseWithTransport |
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
32 |
from ..rio import read_stanzas, read_stanzas_unicode |
|
0.8.1
by John Arbash Meinel
Creating a plugin to ease generating version information from a tree. |
33 |
|
|
6734.1.17
by Jelmer Vernooij
Move format custom errors. |
34 |
from ..version_info_formats.format_custom import ( |
35 |
CustomVersionInfoBuilder, |
|
36 |
MissingTemplateVariable, |
|
37 |
NoTemplate, |
|
38 |
)
|
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
39 |
from ..version_info_formats.format_rio import RioVersionInfoBuilder |
40 |
from ..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. |
41 |
|
42 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
43 |
class VersionInfoTestCase(TestCaseWithTransport): |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
44 |
|
45 |
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. |
46 |
wt = self.make_branch_and_tree('branch') |
|
0.8.23
by John Arbash Meinel
whitespace and formatting cleanups. |
47 |
|
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
48 |
self.build_tree(['branch/a']) |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
49 |
wt.add('a') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
50 |
wt.commit('a', rev_id=b'r1') |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
51 |
|
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
52 |
self.build_tree(['branch/b']) |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
53 |
wt.add('b') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
54 |
wt.commit('b', rev_id=b'r2') |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
55 |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
56 |
self.build_tree_contents([('branch/a', b'new contents\n')]) |
57 |
wt.commit(u'\xe52', rev_id=b'r3') |
|
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
58 |
|
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
59 |
return wt |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
60 |
|
|
5967.11.4
by Benoît Pierre
Rename tests helper "create_tree_on_dotted_revno" to "create_tree_with_dotted_revno". |
61 |
def create_tree_with_dotted_revno(self): |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
62 |
wt = self.make_branch_and_tree('branch') |
63 |
self.build_tree(['branch/a']) |
|
64 |
wt.add('a') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
65 |
wt.commit('a', rev_id=b'r1') |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
66 |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
67 |
other = wt.controldir.sprout('other').open_workingtree() |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
68 |
self.build_tree(['other/b.a']) |
69 |
other.add(['b.a']) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
70 |
other.commit('b.a', rev_id=b'o2') |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
71 |
|
72 |
os.chdir('branch') |
|
73 |
self.run_bzr('merge ../other') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
74 |
wt.commit('merge', rev_id=b'merge') |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
75 |
|
|
7045.1.13
by Jelmer Vernooij
Fix a few more tests. |
76 |
wt.update(revision=b'o2') |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
77 |
|
78 |
return wt |
|
79 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
80 |
|
81 |
class TestVersionInfoRio(VersionInfoTestCase): |
|
82 |
||
|
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
83 |
def test_rio_null(self): |
84 |
wt = self.make_branch_and_tree('branch') |
|
85 |
||
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
86 |
sio = StringIO() |
|
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
87 |
builder = RioVersionInfoBuilder(wt.branch, working_tree=wt) |
88 |
builder.generate(sio) |
|
89 |
val = sio.getvalue() |
|
90 |
self.assertContainsRe(val, 'build-date:') |
|
91 |
self.assertContainsRe(val, 'revno: 0') |
|
92 |
||
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
93 |
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". |
94 |
wt = self.create_tree_with_dotted_revno() |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
95 |
|
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
96 |
sio = StringIO() |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
97 |
builder = RioVersionInfoBuilder(wt.branch, working_tree=wt) |
98 |
builder.generate(sio) |
|
99 |
val = sio.getvalue() |
|
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
100 |
self.assertContainsRe(val, 'revno: 1.1.1') |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
101 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
102 |
def regen_text(self, wt, **kwargs): |
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
103 |
sio = StringIO() |
|
6406.1.4
by Jelmer Vernooij
Fix some indentation. |
104 |
builder = RioVersionInfoBuilder(wt.branch, working_tree=wt, **kwargs) |
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
105 |
builder.generate(sio) |
106 |
val = sio.getvalue() |
|
107 |
return val |
|
108 |
||
109 |
def test_simple(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. |
110 |
wt = self.create_branch() |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
111 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
112 |
val = self.regen_text(wt) |
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
113 |
self.assertContainsRe(val, 'build-date:') |
114 |
self.assertContainsRe(val, 'date:') |
|
115 |
self.assertContainsRe(val, 'revno: 3') |
|
116 |
self.assertContainsRe(val, 'revision-id: r3') |
|
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
117 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
118 |
def test_clean(self): |
119 |
wt = self.create_branch() |
|
120 |
val = self.regen_text(wt, check_for_clean=True) |
|
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
121 |
self.assertContainsRe(val, 'clean: True') |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
122 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
123 |
def test_no_clean(self): |
124 |
wt = self.create_branch() |
|
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
125 |
self.build_tree(['branch/c']) |
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
126 |
val = self.regen_text(wt, check_for_clean=True) |
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
127 |
self.assertContainsRe(val, 'clean: False') |
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
128 |
|
129 |
def test_history(self): |
|
130 |
wt = self.create_branch() |
|
131 |
||
132 |
val = self.regen_text(wt, include_revision_history=True) |
|
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
133 |
self.assertContainsRe(val, 'id: r1') |
134 |
self.assertContainsRe(val, 'message: a') |
|
135 |
self.assertContainsRe(val, 'id: r2') |
|
136 |
self.assertContainsRe(val, 'message: b') |
|
137 |
self.assertContainsRe(val, 'id: r3') |
|
138 |
self.assertContainsRe(val, 'message: \xe5') |
|
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
139 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
140 |
def regen(self, wt, **kwargs): |
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
141 |
sio = StringIO() |
|
6406.1.4
by Jelmer Vernooij
Fix some indentation. |
142 |
builder = RioVersionInfoBuilder(wt.branch, working_tree=wt, **kwargs) |
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
143 |
builder.generate(sio) |
144 |
sio.seek(0) |
|
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
145 |
stanzas = list(read_stanzas_unicode(sio)) |
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
146 |
self.assertEqual(1, len(stanzas)) |
147 |
return stanzas[0] |
|
148 |
||
|
4216.4.1
by Jelmer Vernooij
Allow hooks to add new entries to version-info. |
149 |
def test_rio_version_hook(self): |
150 |
def update_stanza(rev, stanza): |
|
151 |
stanza.add('bla', 'bloe') |
|
152 |
RioVersionInfoBuilder.hooks.install_named_hook( |
|
153 |
'revision', update_stanza, None) |
|
154 |
wt = self.create_branch() |
|
155 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
156 |
stanza = self.regen(wt) |
|
4216.4.1
by Jelmer Vernooij
Allow hooks to add new entries to version-info. |
157 |
self.assertEqual(['bloe'], stanza.get_all('bla')) |
158 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
159 |
def get_one_stanza(self, stanza, key): |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
160 |
new_stanzas = list(read_stanzas(BytesIO(stanza[key].encode('utf8')))) |
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
161 |
self.assertEqual(1, len(new_stanzas)) |
162 |
return new_stanzas[0] |
|
163 |
||
164 |
def test_build_date(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. |
165 |
wt = self.create_branch() |
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
166 |
stanza = self.regen(wt) |
|
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 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
172 |
def test_not_clean(self): |
173 |
wt = self.create_branch() |
|
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
174 |
self.build_tree(['branch/c']) |
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
175 |
stanza = self.regen(wt, 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. |
176 |
self.assertEqual(['False'], stanza.get_all('clean')) |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
177 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
178 |
def test_file_revisions(self): |
179 |
wt = self.create_branch() |
|
180 |
self.build_tree(['branch/c']) |
|
181 |
stanza = self.regen(wt, check_for_clean=True, include_file_revisions=True) |
|
|
4599.4.2
by Robert Collins
Update test_version_info for rich root test data. |
182 |
# This assumes it's being run against a tree that does not update the
|
183 |
# root revision on every commit.
|
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
184 |
file_rev_stanza = self.get_one_stanza(stanza, 'file-revisions') |
|
1731.1.50
by Aaron Bentley
Merge bzr.dev |
185 |
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. |
186 |
self.assertEqual(['r1', 'r3', 'r2', 'unversioned'], |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
187 |
file_rev_stanza.get_all('revision')) |
|
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
188 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
189 |
def test_revision_history(self): |
190 |
wt = self.create_branch() |
|
191 |
stanza = self.regen(wt, include_revision_history=True) |
|
192 |
revision_stanza = self.get_one_stanza(stanza, 'revisions') |
|
|
0.8.7
by John Arbash Meinel
Adding tests for parsing the rio text back into rio. |
193 |
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 |
194 |
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. |
195 |
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. |
196 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
197 |
def test_file_revisions_with_rename(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. |
198 |
# a was modified, so it should show up modified again
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
199 |
wt = self.create_branch() |
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
200 |
self.build_tree(['branch/a', 'branch/c']) |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
201 |
wt.add('c') |
202 |
wt.rename_one('b', 'd') |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
203 |
stanza = self.regen(wt, check_for_clean=True, include_file_revisions=True) |
204 |
file_rev_stanza = self.get_one_stanza(stanza, 'file-revisions') |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
205 |
self.assertEqual(['', 'a', 'b', 'c', 'd'], |
|
1731.1.50
by Aaron Bentley
Merge bzr.dev |
206 |
file_rev_stanza.get_all('path')) |
|
4599.4.2
by Robert Collins
Update test_version_info for rich root test data. |
207 |
self.assertEqual(['r1', 'modified', 'renamed to d', 'new', |
|
1731.1.50
by Aaron Bentley
Merge bzr.dev |
208 |
'renamed from b'], |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
209 |
file_rev_stanza.get_all('revision')) |
210 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
211 |
def test_file_revisions_with_removal(self): |
212 |
wt = self.create_branch() |
|
213 |
self.build_tree(['branch/a', 'branch/c']) |
|
214 |
wt.add('c') |
|
215 |
wt.rename_one('b', 'd') |
|
216 |
||
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
217 |
wt.commit('modified', rev_id=b'r4') |
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
218 |
|
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
219 |
wt.remove(['c', 'd']) |
220 |
os.remove('branch/d') |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
221 |
stanza = self.regen(wt, check_for_clean=True, include_file_revisions=True) |
222 |
file_rev_stanza = self.get_one_stanza(stanza, 'file-revisions') |
|
|
1731.1.50
by Aaron Bentley
Merge bzr.dev |
223 |
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. |
224 |
self.assertEqual(['r1', 'r4', 'unversioned', 'removed'], |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
225 |
file_rev_stanza.get_all('revision')) |
226 |
||
|
6406.1.3
by Jelmer Vernooij
Fix version_info tree. |
227 |
def test_revision(self): |
228 |
wt = self.create_branch() |
|
229 |
self.build_tree(['branch/a', 'branch/c']) |
|
230 |
wt.add('c') |
|
231 |
wt.rename_one('b', 'd') |
|
232 |
||
233 |
stanza = self.regen(wt, check_for_clean=True, |
|
234 |
include_file_revisions=True, revision_id=wt.last_revision()) |
|
235 |
file_rev_stanza = self.get_one_stanza(stanza, 'file-revisions') |
|
236 |
self.assertEqual(['', 'a', 'b'], file_rev_stanza.get_all('path')) |
|
237 |
self.assertEqual(['r1', 'r3', 'r2'], |
|
238 |
file_rev_stanza.get_all('revision')) |
|
239 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
240 |
|
241 |
class PythonVersionInfoTests(VersionInfoTestCase): |
|
242 |
||
|
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
243 |
def test_python_null(self): |
244 |
wt = self.make_branch_and_tree('branch') |
|
245 |
||
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
246 |
sio = StringIO() |
|
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
247 |
builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt) |
248 |
builder.generate(sio) |
|
249 |
val = sio.getvalue() |
|
250 |
self.assertContainsRe(val, "'revision_id': None") |
|
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
251 |
self.assertContainsRe(val, "'revno': '0'") |
|
5598.1.1
by Soren Hansen
Fix PEP-8 violation in PythonVersionInfoBuilder's output |
252 |
self.assertNotContainsString(val, '\n\n\n\n') |
|
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
253 |
|
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
254 |
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". |
255 |
wt = self.create_tree_with_dotted_revno() |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
256 |
|
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
257 |
sio = StringIO() |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
258 |
builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt) |
259 |
builder.generate(sio) |
|
260 |
val = sio.getvalue() |
|
261 |
self.assertContainsRe(val, "'revno': '1.1.1'") |
|
262 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
263 |
def regen(self, wt, **kwargs): |
264 |
"""Create a test module, import and return it""" |
|
|
7078.3.2
by Jelmer Vernooij
Avoid using imp to do python version info validation. |
265 |
builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt, |
266 |
**kwargs) |
|
267 |
outf = StringIO() |
|
268 |
builder.generate(outf) |
|
269 |
local_vars = {} |
|
270 |
exec(outf.getvalue(), {}, local_vars) |
|
271 |
return local_vars |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
272 |
|
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
273 |
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. |
274 |
wt = self.create_branch() |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
275 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
276 |
tvi = self.regen(wt) |
|
7078.3.2
by Jelmer Vernooij
Avoid using imp to do python version info validation. |
277 |
self.assertEqual('3', tvi['version_info']['revno']) |
278 |
self.assertEqual(b'r3', tvi['version_info']['revision_id']) |
|
279 |
self.assertTrue('date' in tvi['version_info']) |
|
280 |
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 |
281 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
282 |
tvi = self.regen(wt, check_for_clean=True) |
|
7078.3.2
by Jelmer Vernooij
Avoid using imp to do python version info validation. |
283 |
self.assertTrue(tvi['version_info']['clean']) |
|
0.8.5
by John Arbash Meinel
Adding some whitebox tests for the output of generate_version_info |
284 |
|
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
285 |
self.build_tree(['branch/c']) |
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
286 |
tvi = self.regen(wt, check_for_clean=True, include_file_revisions=True) |
|
7078.3.2
by Jelmer Vernooij
Avoid using imp to do python version info validation. |
287 |
self.assertFalse(tvi['version_info']['clean']) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
288 |
self.assertEqual(['', 'a', 'b', 'c'], |
|
7078.3.2
by Jelmer Vernooij
Avoid using imp to do python version info validation. |
289 |
sorted(tvi['file_revisions'].keys())) |
290 |
self.assertEqual(b'r3', tvi['file_revisions']['a']) |
|
291 |
self.assertEqual(b'r2', tvi['file_revisions']['b']) |
|
292 |
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 |
293 |
os.remove('branch/c') |
294 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
295 |
tvi = self.regen(wt, include_revision_history=True) |
|
0.8.15
by John Arbash Meinel
Including the date stamp for all revisions. |
296 |
|
|
0.8.23
by John Arbash Meinel
whitespace and formatting cleanups. |
297 |
rev_info = [(rev, message) for rev, message, timestamp, timezone |
|
7078.3.2
by Jelmer Vernooij
Avoid using imp to do python version info validation. |
298 |
in tvi['revisions']] |
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
299 |
self.assertEqual([(b'r1', 'a'), (b'r2', 'b'), (b'r3', u'\xe52')], rev_info) |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
300 |
|
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
301 |
# a was modified, so it should show up modified again
|
302 |
self.build_tree(['branch/a', 'branch/c']) |
|
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
303 |
wt.add('c') |
304 |
wt.rename_one('b', 'd') |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
305 |
tvi = self.regen(wt, check_for_clean=True, include_file_revisions=True) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
306 |
self.assertEqual(['', 'a', 'b', 'c', 'd'], |
|
7078.3.2
by Jelmer Vernooij
Avoid using imp to do python version info validation. |
307 |
sorted(tvi['file_revisions'].keys())) |
308 |
self.assertEqual('modified', tvi['file_revisions']['a']) |
|
309 |
self.assertEqual('renamed to d', tvi['file_revisions']['b']) |
|
310 |
self.assertEqual('new', tvi['file_revisions']['c']) |
|
311 |
self.assertEqual('renamed from b', tvi['file_revisions']['d']) |
|
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
312 |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
313 |
wt.commit('modified', rev_id=b'r4') |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
314 |
wt.remove(['c', 'd']) |
315 |
os.remove('branch/d') |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
316 |
tvi = self.regen(wt, check_for_clean=True, include_file_revisions=True) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
317 |
self.assertEqual(['', 'a', 'c', 'd'], |
|
7078.3.2
by Jelmer Vernooij
Avoid using imp to do python version info validation. |
318 |
sorted(tvi['file_revisions'].keys())) |
319 |
self.assertEqual(b'r4', tvi['file_revisions']['a']) |
|
320 |
self.assertEqual('unversioned', tvi['file_revisions']['c']) |
|
321 |
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 |
322 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
323 |
|
324 |
class CustomVersionInfoTests(VersionInfoTestCase): |
|
325 |
||
|
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
326 |
def test_custom_null(self): |
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
327 |
sio = StringIO() |
|
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
328 |
wt = self.make_branch_and_tree('branch') |
329 |
builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, |
|
330 |
template='revno: {revno}') |
|
331 |
builder.generate(sio) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
332 |
self.assertEqual("revno: 0", sio.getvalue()) |
|
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
333 |
|
334 |
builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, |
|
335 |
template='{revno} revid: {revision_id}') |
|
336 |
# revision_id is not available yet
|
|
|
6734.1.17
by Jelmer Vernooij
Move format custom errors. |
337 |
self.assertRaises(MissingTemplateVariable, builder.generate, sio) |
|
4250.1.1
by Jelmer Vernooij
Fix version-info in empty branches. |
338 |
|
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
339 |
def test_custom_dotted_revno(self): |
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
340 |
sio = StringIO() |
|
5967.11.4
by Benoît Pierre
Rename tests helper "create_tree_on_dotted_revno" to "create_tree_with_dotted_revno". |
341 |
wt = self.create_tree_with_dotted_revno() |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
342 |
builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, |
343 |
template='{revno} revid: {revision_id}') |
|
344 |
builder.generate(sio) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
345 |
self.assertEqual("1.1.1 revid: o2", sio.getvalue()) |
|
5967.11.1
by Benoît Pierre
Update version-info tests. |
346 |
|
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
347 |
def regen(self, wt, tpl, **kwargs): |
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
348 |
sio = StringIO() |
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
349 |
builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt, |
350 |
template=tpl, **kwargs) |
|
351 |
builder.generate(sio) |
|
352 |
val = sio.getvalue() |
|
353 |
return val |
|
354 |
||
355 |
def test_build_date(self): |
|
|
2948.4.1
by Lukáš Lalinský
Custom template-based version info formatter. |
356 |
wt = self.create_branch() |
357 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
358 |
val = self.regen(wt, 'build-date: "{build_date}"\ndate: "{date}"') |
|
2948.4.1
by Lukáš Lalinský
Custom template-based version info formatter. |
359 |
self.assertContainsRe(val, 'build-date: "[0-9-+: ]+"') |
360 |
self.assertContainsRe(val, 'date: "[0-9-+: ]+"') |
|
361 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
362 |
def test_revno(self): |
363 |
wt = self.create_branch() |
|
364 |
val = self.regen(wt, 'revno: {revno}') |
|
|
2948.4.1
by Lukáš Lalinský
Custom template-based version info formatter. |
365 |
self.assertEqual(val, 'revno: 3') |
366 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
367 |
def test_revision_id(self): |
368 |
wt = self.create_branch() |
|
369 |
val = self.regen(wt, 'revision-id: {revision_id}') |
|
|
2948.4.1
by Lukáš Lalinský
Custom template-based version info formatter. |
370 |
self.assertEqual(val, 'revision-id: r3') |
371 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
372 |
def test_clean(self): |
373 |
wt = self.create_branch() |
|
374 |
val = self.regen(wt, 'clean: {clean}', check_for_clean=True) |
|
|
2948.4.1
by Lukáš Lalinský
Custom template-based version info formatter. |
375 |
self.assertEqual(val, 'clean: 1') |
376 |
||
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
377 |
def test_not_clean(self): |
378 |
wt = self.create_branch() |
|
379 |
||
|
2948.4.1
by Lukáš Lalinský
Custom template-based version info formatter. |
380 |
self.build_tree(['branch/c']) |
|
6406.1.1
by Jelmer Vernooij
Split up version info tests. |
381 |
val = self.regen(wt, 'clean: {clean}', check_for_clean=True) |
|
2948.4.1
by Lukáš Lalinský
Custom template-based version info formatter. |
382 |
self.assertEqual(val, 'clean: 0') |
383 |
os.remove('branch/c') |
|
|
3138.1.1
by John Arbash Meinel
Fix bug #175886: version_info deprecated functions should be tested to still work. |
384 |
|
|
3207.1.1
by Lukáš Lalinský
Raise a proper error when 'version-info --custom' is used without a template |
385 |
def test_custom_without_template(self): |
386 |
builder = CustomVersionInfoBuilder(None) |
|
|
7045.1.15
by Jelmer Vernooij
fix version info tests |
387 |
sio = StringIO() |
|
6734.1.17
by Jelmer Vernooij
Move format custom errors. |
388 |
self.assertRaises(NoTemplate, builder.generate, sio) |
|
3207.1.1
by Lukáš Lalinský
Raise a proper error when 'version-info --custom' is used without a template |
389 |
|
|
3138.1.1
by John Arbash Meinel
Fix bug #175886: version_info deprecated functions should be tested to still work. |
390 |
|
391 |
class TestBuilder(version_info_formats.VersionInfoBuilder): |
|
392 |
pass
|
|
393 |
||
394 |
||
395 |
class TestVersionInfoFormatRegistry(tests.TestCase): |
|
396 |
||
397 |
def setUp(self): |
|
398 |
super(TestVersionInfoFormatRegistry, self).setUp() |
|
|
4985.1.5
by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity |
399 |
self.overrideAttr(version_info_formats, |
400 |
'format_registry', registry.Registry()) |
|
|
3138.1.1
by John Arbash Meinel
Fix bug #175886: version_info deprecated functions should be tested to still work. |
401 |
|
402 |
def test_register_remove(self): |
|
403 |
registry = version_info_formats.format_registry |
|
404 |
registry.register('testbuilder', |
|
405 |
TestBuilder, 'a simple test builder') |
|
406 |
self.assertIs(TestBuilder, registry.get('testbuilder')) |
|
407 |
self.assertEqual('a simple test builder', |
|
408 |
registry.get_help('testbuilder')) |
|
409 |
registry.remove('testbuilder') |
|
410 |
self.assertRaises(KeyError, registry.get, 'testbuilder') |