bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
1 |
# Copyright (C) 2007, 2009-2012 Canonical Ltd
|
|
2604.2.1
by Robert Collins
(robertc) Introduce a pack command. |
2 |
#
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
2604.2.1
by Robert Collins
(robertc) Introduce a pack command. |
16 |
#
|
17 |
||
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
18 |
"""Tests of the 'brz pack' command."""
|
|
5108.1.2
by Parth Malwankar
added test case for --create-obsolete-packs |
19 |
import os |
|
2604.2.1
by Robert Collins
(robertc) Introduce a pack command. |
20 |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
21 |
from breezy import tests |
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
22 |
|
23 |
||
24 |
class TestPack(tests.TestCaseWithTransport): |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
25 |
|
|
5108.1.2
by Parth Malwankar
added test case for --create-obsolete-packs |
26 |
def _make_versioned_file(self, path, line_prefix='line', total_lines=10): |
27 |
self._make_file(path, line_prefix, total_lines, versioned=True) |
|
28 |
||
29 |
def _make_file(self, path, line_prefix, total_lines, versioned): |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
30 |
text = '' |
|
5108.1.2
by Parth Malwankar
added test case for --create-obsolete-packs |
31 |
for i in range(total_lines): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
32 |
text += line_prefix + str(i + 1) + "\n" |
|
5108.1.2
by Parth Malwankar
added test case for --create-obsolete-packs |
33 |
|
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
34 |
with open(path, 'w') as f: |
35 |
f.write(text) |
|
|
5108.1.2
by Parth Malwankar
added test case for --create-obsolete-packs |
36 |
if versioned: |
37 |
self.run_bzr(['add', path]) |
|
38 |
self.run_bzr(['ci', '-m', '"' + path + '"']) |
|
39 |
||
40 |
def _update_file(self, path, text, checkin=True): |
|
41 |
"""append text to file 'path' and check it in""" |
|
|
5861.2.1
by Wouter van Heyst
Stop depending on CPython refcounting semantics to close files. |
42 |
with open(path, 'a') as f: |
43 |
f.write(text) |
|
44 |
||
|
5108.1.2
by Parth Malwankar
added test case for --create-obsolete-packs |
45 |
if checkin: |
46 |
self.run_bzr(['ci', path, '-m', '"' + path + '"']) |
|
47 |
||
|
2604.2.1
by Robert Collins
(robertc) Introduce a pack command. |
48 |
def test_pack_silent(self): |
49 |
"""pack command has no intrinsic output.""" |
|
50 |
self.make_branch('.') |
|
51 |
out, err = self.run_bzr('pack') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
52 |
self.assertEqual('', out) |
53 |
self.assertEqual('', err) |
|
|
2604.2.1
by Robert Collins
(robertc) Introduce a pack command. |
54 |
|
55 |
def test_pack_accepts_branch_url(self): |
|
56 |
"""pack command accepts the url to a branch.""" |
|
57 |
self.make_branch('branch') |
|
58 |
out, err = self.run_bzr('pack branch') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
59 |
self.assertEqual('', out) |
60 |
self.assertEqual('', err) |
|
|
2604.2.1
by Robert Collins
(robertc) Introduce a pack command. |
61 |
|
62 |
def test_pack_accepts_repo_url(self): |
|
63 |
"""pack command accepts the url to a branch.""" |
|
64 |
self.make_repository('repository') |
|
65 |
out, err = self.run_bzr('pack repository') |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
66 |
self.assertEqual('', out) |
67 |
self.assertEqual('', err) |
|
|
5108.1.2
by Parth Malwankar
added test case for --create-obsolete-packs |
68 |
|
69 |
def test_pack_clean_obsolete_packs(self): |
|
70 |
"""Ensure --clean-obsolete-packs removes obsolete pack files |
|
71 |
"""
|
|
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
72 |
wt = self.make_branch_and_tree('.') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
73 |
t = wt.branch.repository.controldir.transport |
|
5108.1.2
by Parth Malwankar
added test case for --create-obsolete-packs |
74 |
|
75 |
# do multiple commits to ensure that obsolete packs are created
|
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
76 |
# by 'brz pack'
|
|
5108.1.2
by Parth Malwankar
added test case for --create-obsolete-packs |
77 |
self._make_versioned_file('file0.txt') |
78 |
for i in range(5): |
|
79 |
self._update_file('file0.txt', 'HELLO %d\n' % i) |
|
80 |
||
81 |
out, err = self.run_bzr(['pack', '--clean-obsolete-packs']) |
|
82 |
||
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
83 |
pack_names = t.list_dir('repository/obsolete_packs') |
|
5108.1.2
by Parth Malwankar
added test case for --create-obsolete-packs |
84 |
self.assertTrue(len(pack_names) == 0) |