5171.3.7
by Martin von Gagern
Added blackbox tests for --directory option. |
1 |
# Copyright (C) 2005-2010 Canonical Ltd
|
4020.1.2
by Jelmer Vernooij
Import blackbox test for clean-tree, run regular 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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
4020.1.2
by Jelmer Vernooij
Import blackbox test for clean-tree, run regular tests. |
16 |
#
|
17 |
||
4020.1.5
by Aaron Bentley
Fix some formatting issues. |
18 |
|
4020.1.2
by Jelmer Vernooij
Import blackbox test for clean-tree, run regular tests. |
19 |
"""Tests of the 'bzr clean-tree' command."""
|
20 |
||
4020.1.5
by Aaron Bentley
Fix some formatting issues. |
21 |
|
4020.1.2
by Jelmer Vernooij
Import blackbox test for clean-tree, run regular tests. |
22 |
import os |
23 |
||
5195.4.1
by Alexander Belchenko
added test to illustrate bug https://bugs.launchpad.net/bzr/+bug/572098. Currently test failed as expected. |
24 |
from bzrlib import ignores |
4020.1.2
by Jelmer Vernooij
Import blackbox test for clean-tree, run regular tests. |
25 |
from bzrlib.tests import TestCaseWithTransport |
6228.1.2
by Benoît Pierre
Add a clean_tree test to check interactive prompt behaviour. |
26 |
from bzrlib.tests.script import run_script |
4020.1.2
by Jelmer Vernooij
Import blackbox test for clean-tree, run regular tests. |
27 |
|
28 |
||
29 |
class TestBzrTools(TestCaseWithTransport): |
|
30 |
||
31 |
@staticmethod
|
|
32 |
def touch(filename): |
|
4020.1.4
by Aaron Bentley
Assign copyright, update tests. |
33 |
my_file = open(filename, 'wb') |
34 |
try: |
|
35 |
my_file.write('') |
|
36 |
finally: |
|
37 |
my_file.close() |
|
4020.1.2
by Jelmer Vernooij
Import blackbox test for clean-tree, run regular tests. |
38 |
|
39 |
def test_clean_tree(self): |
|
40 |
self.run_bzr('init') |
|
41 |
self.run_bzr('ignore *~') |
|
42 |
self.run_bzr('ignore *.pyc') |
|
43 |
self.touch('name') |
|
44 |
self.touch('name~') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
45 |
self.assertPathExists('name~') |
4020.1.2
by Jelmer Vernooij
Import blackbox test for clean-tree, run regular tests. |
46 |
self.touch('name.pyc') |
47 |
self.run_bzr('clean-tree --force') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
48 |
self.assertPathExists('name~') |
49 |
self.assertPathDoesNotExist('name') |
|
4020.1.2
by Jelmer Vernooij
Import blackbox test for clean-tree, run regular tests. |
50 |
self.touch('name') |
51 |
self.run_bzr('clean-tree --detritus --force') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
52 |
self.assertPathExists('name') |
53 |
self.assertPathDoesNotExist('name~') |
|
54 |
self.assertPathExists('name.pyc') |
|
4020.1.2
by Jelmer Vernooij
Import blackbox test for clean-tree, run regular tests. |
55 |
self.run_bzr('clean-tree --ignored --force') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
56 |
self.assertPathExists('name') |
57 |
self.assertPathDoesNotExist('name.pyc') |
|
4020.1.2
by Jelmer Vernooij
Import blackbox test for clean-tree, run regular tests. |
58 |
self.run_bzr('clean-tree --unknown --force') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
59 |
self.assertPathDoesNotExist('name') |
4020.1.2
by Jelmer Vernooij
Import blackbox test for clean-tree, run regular tests. |
60 |
self.touch('name') |
61 |
self.touch('name~') |
|
62 |
self.touch('name.pyc') |
|
63 |
self.run_bzr('clean-tree --unknown --ignored --force') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
64 |
self.assertPathDoesNotExist('name') |
65 |
self.assertPathDoesNotExist('name~') |
|
66 |
self.assertPathDoesNotExist('name.pyc') |
|
5195.4.1
by Alexander Belchenko
added test to illustrate bug https://bugs.launchpad.net/bzr/+bug/572098. Currently test failed as expected. |
67 |
|
68 |
def test_clean_tree_nested_bzrdir(self): |
|
5195.4.5
by Alexander Belchenko
improved tests based on review of vila and parthm |
69 |
# clean-tree should not blindly delete nested bzrdirs (branches)
|
5195.4.1
by Alexander Belchenko
added test to illustrate bug https://bugs.launchpad.net/bzr/+bug/572098. Currently test failed as expected. |
70 |
# bug https://bugs.launchpad.net/bzr/+bug/572098
|
5195.4.5
by Alexander Belchenko
improved tests based on review of vila and parthm |
71 |
# so it will play well with scmproj/bzr-externals plugins.
|
5195.4.1
by Alexander Belchenko
added test to illustrate bug https://bugs.launchpad.net/bzr/+bug/572098. Currently test failed as expected. |
72 |
wt1 = self.make_branch_and_tree('.') |
73 |
wt2 = self.make_branch_and_tree('foo') |
|
74 |
wt3 = self.make_branch_and_tree('bar') |
|
75 |
ignores.tree_ignores_add_patterns(wt1, ['./foo']) |
|
5195.4.5
by Alexander Belchenko
improved tests based on review of vila and parthm |
76 |
self.run_bzr(['clean-tree', '--unknown', '--force']) |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
77 |
self.assertPathExists('foo') |
78 |
self.assertPathExists('bar') |
|
5195.4.5
by Alexander Belchenko
improved tests based on review of vila and parthm |
79 |
self.run_bzr(['clean-tree', '--ignored', '--force']) |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
80 |
self.assertPathExists('foo') |
81 |
self.assertPathExists('bar') |
|
5195.4.7
by Gary van der Merwe
Merge bzr.dev. |
82 |
|
5171.3.7
by Martin von Gagern
Added blackbox tests for --directory option. |
83 |
def test_clean_tree_directory(self): |
84 |
"""Test --directory option"""
|
|
85 |
tree = self.make_branch_and_tree('a') |
|
86 |
self.build_tree(['a/added', 'a/unknown', 'a/ignored']) |
|
87 |
tree.add('added') |
|
88 |
self.run_bzr('clean-tree -d a --unknown --ignored --force') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
89 |
self.assertPathDoesNotExist('a/unknown') |
90 |
self.assertPathDoesNotExist('a/ignored') |
|
91 |
self.assertPathExists('a/added') |
|
6228.1.2
by Benoît Pierre
Add a clean_tree test to check interactive prompt behaviour. |
92 |
|
93 |
def test_clean_tree_interactive(self): |
|
94 |
wt = self.make_branch_and_tree('.') |
|
95 |
self.touch('bar') |
|
96 |
self.touch('foo') |
|
97 |
run_script(self, """ |
|
98 |
$ bzr clean-tree
|
|
99 |
bar
|
|
100 |
foo
|
|
101 |
2>Are you sure you wish to delete these? ([y]es, [n]o): no
|
|
102 |
<n
|
|
103 |
Canceled
|
|
104 |
""") |
|
105 |
self.assertPathExists('bar') |
|
106 |
self.assertPathExists('foo') |
|
107 |
run_script(self, """ |
|
108 |
$ bzr clean-tree
|
|
109 |
bar
|
|
110 |
foo
|
|
111 |
2>Are you sure you wish to delete these? ([y]es, [n]o): yes
|
|
112 |
<y
|
|
113 |
2>deleting paths:
|
|
114 |
2> bar
|
|
115 |
2> foo
|
|
116 |
""") |
|
117 |
self.assertPathDoesNotExist('bar') |
|
118 |
self.assertPathDoesNotExist('foo') |