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 |
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
22 |
|
23 |
||
24 |
class TestVersionInfo(TestCaseWithTransport): |
|
0.8.2
by John Arbash Meinel
Have working rio output |
25 |
|
26 |
def test_invalid_format(self): |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
27 |
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. |
28 |
|
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
29 |
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. |
30 |
wt = self.make_branch_and_tree('branch') |
0.8.23
by John Arbash Meinel
whitespace and formatting cleanups. |
31 |
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
32 |
self.build_tree(['branch/a']) |
33 |
wt.add('a') |
|
34 |
wt.commit('adding a', rev_id='r1') |
|
35 |
||
36 |
self.build_tree(['branch/b']) |
|
37 |
wt.add('b') |
|
38 |
wt.commit('adding b', rev_id='r2') |
|
39 |
||
40 |
self.revisions = wt.branch.revision_history() |
|
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
41 |
return wt |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
42 |
|
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
43 |
def test_basic(self): |
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
44 |
self.create_tree() |
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
45 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
46 |
txt = self.run_bzr('version-info branch')[0] |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
47 |
self.assertContainsRe(txt, 'date:') |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
48 |
self.assertContainsRe(txt, 'build-date:') |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
49 |
self.assertContainsRe(txt, 'revno: 2') |
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
50 |
self.assertContainsRe(txt, 'revision-id: ' + self.revisions[-1]) |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
51 |
|
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
52 |
def test_all(self): |
53 |
"""'--all' includes clean, revision history, and file revisions"""
|
|
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
54 |
self.create_tree() |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
55 |
txt = self.run_bzr('version-info branch --all')[0] |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
56 |
self.assertContainsRe(txt, 'date:') |
57 |
self.assertContainsRe(txt, 'revno: 2') |
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
58 |
self.assertContainsRe(txt, 'revision-id: ' + self.revisions[-1]) |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
59 |
self.assertContainsRe(txt, 'clean: True') |
60 |
self.assertContainsRe(txt, 'revisions:') |
|
0.8.20
by John Arbash Meinel
Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass. |
61 |
for rev_id in self.revisions: |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
62 |
self.assertContainsRe(txt, 'id: ' + rev_id) |
63 |
self.assertContainsRe(txt, 'message: adding a') |
|
64 |
self.assertContainsRe(txt, 'message: adding b') |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
65 |
self.assertContainsRe(txt, 'file-revisions:') |
66 |
self.assertContainsRe(txt, 'path: a') |
|
67 |
self.assertContainsRe(txt, 'path: b') |
|
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
68 |
|
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
69 |
def test_clean(self): |
70 |
"""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 |
71 |
self.create_tree() |
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
72 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
73 |
txt = self.run_bzr('version-info branch --check-clean')[0] |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
74 |
self.assertContainsRe(txt, 'clean: True') |
75 |
||
2022.1.4
by John Arbash Meinel
test feedback from Robert. |
76 |
self.build_tree_contents([('branch/c', 'now unclean\n')]) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
77 |
txt = self.run_bzr('version-info branch --check-clean')[0] |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
78 |
self.assertContainsRe(txt, 'clean: False') |
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
79 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
80 |
txt = self.run_bzr('version-info branch --check-clean' |
81 |
' --include-file-revisions')[0] |
|
0.8.13
by John Arbash Meinel
Including file-revisions fields, updated test suite. |
82 |
self.assertContainsRe(txt, 'revision: unversioned') |
83 |
||
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
84 |
os.remove('branch/c') |
85 |
||
2030.1.4
by John Arbash Meinel
Add a test that we can find the version info when we only have a branch |
86 |
def test_no_working_tree(self): |
87 |
tree = self.create_tree() |
|
88 |
branch = self.make_branch('just_branch') |
|
89 |
branch.pull(tree.branch) |
|
90 |
||
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
91 |
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 |
92 |
self.assertStartsWith(txt, 'revision-id: r2\n') |
93 |
||
2030.1.3
by John Arbash Meinel
Change comparisons to ignore the build-date field |
94 |
def assertEqualNoBuildDate(self, text1, text2): |
95 |
"""Compare 2 texts, but ignore the build-date field.
|
|
96 |
||
97 |
build-date is the current timestamp, accurate to seconds. But the
|
|
98 |
clock is always ticking, and it may have ticked between the time
|
|
99 |
that text1 and text2 were generated.
|
|
100 |
"""
|
|
101 |
lines1 = text1.splitlines(True) |
|
102 |
lines2 = text2.splitlines(True) |
|
103 |
for line1, line2 in zip(lines1, lines2): |
|
104 |
if line1.startswith('build-date: '): |
|
105 |
self.assertStartsWith(line2, 'build-date: ') |
|
106 |
else: |
|
107 |
self.assertEqual(line1, line2) |
|
108 |
self.assertEqual(len(lines1), len(lines2)) |
|
109 |
||
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
110 |
def test_no_branch(self): |
111 |
"""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 |
112 |
self.create_tree() |
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
113 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
114 |
txt1 = self.run_bzr('version-info branch')[0] |
2022.1.6
by John Arbash Meinel
small cleanup, remove unused imports |
115 |
|
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
116 |
os.chdir('branch') |
2022.1.6
by John Arbash Meinel
small cleanup, remove unused imports |
117 |
txt2 = self.run_bzr('version-info')[0] |
2030.1.3
by John Arbash Meinel
Change comparisons to ignore the build-date field |
118 |
self.assertEqualNoBuildDate(txt1, txt2) |
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
119 |
|
120 |
def test_rio(self): |
|
121 |
"""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 |
122 |
self.create_tree() |
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
123 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
124 |
txt = self.run_bzr('version-info branch')[0] |
125 |
txt1 = self.run_bzr('version-info --format rio branch')[0] |
|
126 |
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 |
127 |
self.assertEqualNoBuildDate(txt, txt1) |
128 |
self.assertEqualNoBuildDate(txt, txt2) |
|
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
129 |
|
130 |
def test_python(self): |
|
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
131 |
"""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 |
132 |
self.create_tree() |
0.8.6
by John Arbash Meinel
Updated the blackbox tests. |
133 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
134 |
txt = self.run_bzr('version-info --format python branch')[0] |
2022.1.5
by John Arbash Meinel
Cleanup and simplify the blackbox tests |
135 |
|
2022.1.6
by John Arbash Meinel
small cleanup, remove unused imports |
136 |
self.assertContainsRe(txt, 'version_info = {') |
3207.1.1
by Lukáš Lalinský
Raise a proper error when 'version-info --custom' is used without a template |
137 |
|
138 |
def test_custom_without_template(self): |
|
139 |
wt = self.make_branch_and_tree('branch') |
|
140 |
out, err = self.run_bzr('version-info --custom', retcode=3) |
|
141 |
self.assertContainsRe(err, r'ERROR: No template specified\.') |
|
3231.2.1
by James Westby
Make version-info --custom imply --all. |
142 |
|
143 |
def test_custom_implies_all(self): |
|
144 |
self.create_tree() |
|
145 |
out, err = self.run_bzr('version-info --custom --template=' |
|
146 |
'"{revno} {branch_nick} {clean}\n" branch') |
|
147 |
self.assertEqual("2 branch 1\n", out) |
|
148 |
self.assertEqual("", err) |
|
149 |
self.build_tree_contents([('branch/c', 'now unclean\n')]) |
|
150 |
out, err = self.run_bzr('version-info --custom --template=' |
|
151 |
'"{revno} {branch_nick} {clean}\n" branch') |
|
152 |
self.assertEqual("2 branch 0\n", out) |
|
153 |
self.assertEqual("", err) |
|
5436.1.2
by Andrej A Antonov
adding test: blackbox.test_version_info.TestVersionInfo.test_non_ascii |
154 |
|
155 |
def test_non_ascii(self): |
|
156 |
"""Test that we can output non-ascii data"""
|
|
157 |
||
158 |
commit_message = u'Non-ascii message with character not in latin-1: \u1234' |
|
159 |
||
5436.1.3
by Andrej A Antonov
tiny simplification (remove unnecessary) in test 'blackbox.test_version_info.TestVersionInfo.test_non_ascii' |
160 |
tree = self.make_branch_and_tree('.') |
5436.1.2
by Andrej A Antonov
adding test: blackbox.test_version_info.TestVersionInfo.test_non_ascii |
161 |
self.build_tree(['a_file']) |
162 |
tree.add('a_file') |
|
163 |
tree.commit(commit_message) |
|
164 |
out, err = self.run_bzr( |
|
165 |
['version-info', '--include-history'], encoding='latin-1') |
|
166 |
||
167 |
self.assertContainsString(out, commit_message.encode('utf-8')) |
|
168 |
||
169 |