~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_version_info.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-16 19:18:39 UTC
  • mto: This revision was merged to the branch mainline in revision 6391.
  • Revision ID: jelmer@samba.org-20111216191839-eg681lxqibi1qxu1
Fix remaining tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
24
24
from bzrlib import (
25
25
    errors,
26
26
    registry,
27
 
    symbol_versioning,
28
27
    tests,
29
28
    version_info_formats,
30
29
    )
54
53
 
55
54
        return wt
56
55
 
 
56
    def create_tree_with_dotted_revno(self):
 
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
 
57
75
    def test_rio_null(self):
58
76
        wt = self.make_branch_and_tree('branch')
59
77
 
64
82
        self.assertContainsRe(val, 'build-date:')
65
83
        self.assertContainsRe(val, 'revno: 0')
66
84
 
 
85
    def test_rio_dotted_revno(self):
 
86
        wt = self.create_tree_with_dotted_revno()
 
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
 
67
94
    def test_rio_version_text(self):
68
95
        wt = self.create_branch()
69
96
 
137
164
            return new_stanzas[0]
138
165
 
139
166
        stanza = regen()
140
 
        self.failUnless('date' in stanza)
141
 
        self.failUnless('build-date' in stanza)
 
167
        self.assertTrue('date' in stanza)
 
168
        self.assertTrue('build-date' in stanza)
142
169
        self.assertEqual(['3'], stanza.get_all('revno'))
143
170
        self.assertEqual(['r3'], stanza.get_all('revision-id'))
144
171
 
192
219
        builder.generate(sio)
193
220
        val = sio.getvalue()
194
221
        self.assertContainsRe(val, "'revision_id': None")
195
 
        self.assertContainsRe(val, "'revno': 0")
 
222
        self.assertContainsRe(val, "'revno': '0'")
 
223
        self.assertNotContainsString(val, '\n\n\n\n')
 
224
 
 
225
    def test_python_dotted_revno(self):
 
226
        wt = self.create_tree_with_dotted_revno()
 
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'")
196
233
 
197
234
    def test_python_version(self):
198
235
        wt = self.create_branch()
223
260
            return tvi
224
261
 
225
262
        tvi = regen()
226
 
        self.assertEqual(3, tvi.version_info['revno'])
 
263
        self.assertEqual('3', tvi.version_info['revno'])
227
264
        self.assertEqual('r3', tvi.version_info['revision_id'])
228
 
        self.failUnless(tvi.version_info.has_key('date'))
 
265
        self.assertTrue(tvi.version_info.has_key('date'))
229
266
        self.assertEqual(None, tvi.version_info['clean'])
230
267
 
231
268
        tvi = regen(check_for_clean=True)
283
320
        self.assertRaises(errors.MissingTemplateVariable, 
284
321
            builder.generate, sio)
285
322
 
 
323
    def test_custom_dotted_revno(self):
 
324
        sio = StringIO()
 
325
        wt = self.create_tree_with_dotted_revno()
 
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
 
286
331
    def test_custom_version_text(self):
287
332
        wt = self.create_branch()
288
333