1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# Copyright (C) 2006 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""Black-box tests for bzr remove-tree."""
import os
from bzrlib.tests.blackbox import ExternalBase
class TestRemoveTree(ExternalBase):
def setUp(self):
super(TestRemoveTree, self).setUp()
self.tree = self.make_branch_and_tree('branch1')
self.build_tree(['branch1/foo'])
self.tree.add('foo')
self.tree.commit('1')
self.failUnlessExists('branch1/foo')
# Success modes
def test_remove_tree_original_branch(self):
os.chdir('branch1')
self.run_bzr('remove-tree')
self.failIfExists('foo')
def test_remove_tree_original_branch_explicit(self):
self.run_bzr('remove-tree branch1')
self.failIfExists('branch1/foo')
def test_remove_tree_sprouted_branch(self):
self.tree.bzrdir.sprout('branch2')
self.failUnlessExists('branch2/foo')
os.chdir('branch2')
self.run_bzr('remove-tree')
self.failIfExists('foo')
def test_remove_tree_sprouted_branch_explicit(self):
self.tree.bzrdir.sprout('branch2')
self.failUnlessExists('branch2/foo')
self.run_bzr('remove-tree branch2')
self.failIfExists('branch2/foo')
def test_remove_tree_checkout(self):
self.tree.branch.create_checkout('branch2', lightweight=False)
self.failUnlessExists('branch2/foo')
os.chdir('branch2')
self.run_bzr('remove-tree')
self.failIfExists('foo')
os.chdir('..')
self.failUnlessExists('branch1/foo')
def test_remove_tree_checkout_explicit(self):
self.tree.branch.create_checkout('branch2', lightweight=False)
self.failUnlessExists('branch2/foo')
self.run_bzr('remove-tree branch2')
self.failIfExists('branch2/foo')
self.failUnlessExists('branch1/foo')
# Failure modes
def test_remove_tree_lightweight_checkout(self):
self.tree.branch.create_checkout('branch2', lightweight=True)
self.failUnlessExists('branch2/foo')
os.chdir('branch2')
output = self.run_bzr_error(
["You cannot remove the working tree from a lightweight checkout"],
'remove-tree', retcode=3)
self.failUnlessExists('foo')
os.chdir('..')
self.failUnlessExists('branch1/foo')
def test_remove_tree_lightweight_checkout_explicit(self):
self.tree.branch.create_checkout('branch2', lightweight=True)
self.failUnlessExists('branch2/foo')
output = self.run_bzr_error(
["You cannot remove the working tree from a lightweight checkout"],
'remove-tree branch2', retcode=3)
self.failUnlessExists('branch2/foo')
self.failUnlessExists('branch1/foo')
def test_remove_tree_empty_dir(self):
os.mkdir('branch2')
os.chdir('branch2')
output = self.run_bzr_error(["Not a branch"],
'remove-tree', retcode=3)
def test_remove_tree_repeatedly(self):
self.run_bzr('remove-tree branch1')
self.failIfExists('branch1/foo')
output = self.run_bzr_error(["No working tree to remove"],
'remove-tree branch1', retcode=3)
def test_remove_tree_remote_path(self):
# TODO: I can't think of a way to implement this...
pass
def test_remove_tree_uncommitted_changes(self):
self.build_tree(['branch1/bar'])
self.tree.add('bar')
output = self.run_bzr_error(["Working tree .* has uncommitted changes"],
'remove-tree branch1', retcode=3)
def test_remove_tree_uncommitted_changes_force(self):
self.build_tree(['branch1/bar'])
self.tree.add('bar')
self.run_bzr('remove-tree branch1 --force')
self.failIfExists('branch1/foo')
self.failUnlessExists('branch1/bar')
|