2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
1 |
# Copyright (C) 2006 Canonical Ltd
|
2127.2.1
by Daniel Silverstone
Add remove-tree and its blackbox tests |
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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
||
2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
18 |
"""Black-box tests for bzr remove-tree."""
|
2127.2.1
by Daniel Silverstone
Add remove-tree and its blackbox tests |
19 |
|
20 |
import os |
|
21 |
||
22 |
from bzrlib.tests.blackbox import ExternalBase |
|
23 |
||
2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
24 |
|
2127.2.1
by Daniel Silverstone
Add remove-tree and its blackbox tests |
25 |
class TestRemoveTree(ExternalBase): |
26 |
||
2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
27 |
def setUp(self): |
28 |
super(TestRemoveTree, self).setUp() |
|
29 |
self.tree = self.make_branch_and_tree('branch1') |
|
30 |
self.build_tree(['branch1/foo']) |
|
31 |
self.tree.add('foo') |
|
32 |
self.tree.commit('1') |
|
33 |
self.failUnlessExists('branch1/foo') |
|
34 |
||
35 |
# Success modes
|
|
36 |
||
37 |
def test_remove_tree_original_branch(self): |
|
2127.2.1
by Daniel Silverstone
Add remove-tree and its blackbox tests |
38 |
os.chdir('branch1') |
2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
39 |
self.run_bzr('remove-tree') |
40 |
self.failIfExists('foo') |
|
41 |
||
42 |
def test_remove_tree_original_branch_explicit(self): |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
43 |
self.run_bzr('remove-tree branch1') |
2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
44 |
self.failIfExists('branch1/foo') |
45 |
||
46 |
def test_remove_tree_sprouted_branch(self): |
|
47 |
self.tree.bzrdir.sprout('branch2') |
|
48 |
self.failUnlessExists('branch2/foo') |
|
49 |
os.chdir('branch2') |
|
50 |
self.run_bzr('remove-tree') |
|
51 |
self.failIfExists('foo') |
|
52 |
||
53 |
def test_remove_tree_sprouted_branch_explicit(self): |
|
54 |
self.tree.bzrdir.sprout('branch2') |
|
55 |
self.failUnlessExists('branch2/foo') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
56 |
self.run_bzr('remove-tree branch2') |
2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
57 |
self.failIfExists('branch2/foo') |
58 |
||
59 |
def test_remove_tree_checkout(self): |
|
60 |
self.tree.branch.create_checkout('branch2', lightweight=False) |
|
61 |
self.failUnlessExists('branch2/foo') |
|
62 |
os.chdir('branch2') |
|
63 |
self.run_bzr('remove-tree') |
|
64 |
self.failIfExists('foo') |
|
65 |
os.chdir('..') |
|
66 |
self.failUnlessExists('branch1/foo') |
|
67 |
||
68 |
def test_remove_tree_checkout_explicit(self): |
|
69 |
self.tree.branch.create_checkout('branch2', lightweight=False) |
|
70 |
self.failUnlessExists('branch2/foo') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
71 |
self.run_bzr('remove-tree branch2') |
2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
72 |
self.failIfExists('branch2/foo') |
73 |
self.failUnlessExists('branch1/foo') |
|
74 |
||
75 |
# Failure modes
|
|
76 |
||
77 |
def test_remove_tree_lightweight_checkout(self): |
|
78 |
self.tree.branch.create_checkout('branch2', lightweight=True) |
|
79 |
self.failUnlessExists('branch2/foo') |
|
80 |
os.chdir('branch2') |
|
81 |
output = self.run_bzr_error( |
|
2127.2.3
by Daniel Silverstone
Oops, fix the message up |
82 |
["You cannot remove the working tree from a lightweight checkout"], |
2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
83 |
'remove-tree', retcode=3) |
84 |
self.failUnlessExists('foo') |
|
85 |
os.chdir('..') |
|
86 |
self.failUnlessExists('branch1/foo') |
|
87 |
||
88 |
def test_remove_tree_lightweight_checkout_explicit(self): |
|
89 |
self.tree.branch.create_checkout('branch2', lightweight=True) |
|
90 |
self.failUnlessExists('branch2/foo') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
91 |
output = self.run_bzr_error( |
92 |
["You cannot remove the working tree from a lightweight checkout"], |
|
93 |
'remove-tree branch2', retcode=3) |
|
2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
94 |
self.failUnlessExists('branch2/foo') |
95 |
self.failUnlessExists('branch1/foo') |
|
96 |
||
97 |
def test_remove_tree_empty_dir(self): |
|
98 |
os.mkdir('branch2') |
|
99 |
os.chdir('branch2') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
100 |
output = self.run_bzr_error(["Not a branch"], |
101 |
'remove-tree', retcode=3) |
|
2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
102 |
|
103 |
def test_remove_tree_repeatedly(self): |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
104 |
self.run_bzr('remove-tree branch1') |
2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
105 |
self.failIfExists('branch1/foo') |
106 |
output = self.run_bzr_error(["No working tree to remove"], |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
107 |
'remove-tree branch1', retcode=3) |
2127.2.2
by Daniel Silverstone
Refactor the remove-tree stuff after review from J-A-M |
108 |
|
109 |
def test_remove_tree_remote_path(self): |
|
110 |
# TODO: I can't think of a way to implement this...
|
|
111 |
pass
|