20
20
from unittest import makeSuite
22
22
from bzrlib.bzrdir import BzrDir
24
from bzrlib.plugins.bzrtools.clean_tree import clean_tree, iter_deletables
26
from bzrtools.clean_tree import clean_tree, iter_deletables
23
27
from bzrlib.osutils import has_symlinks
24
28
from bzrlib.tests import TestCaseInTempDir
26
from bzrlib.plugins.bzrtools.clean_tree import clean_tree, iter_deletables
28
31
class TestCleanTree(TestCaseInTempDir):
29
32
def test_symlinks(self):
36
39
assert os.path.exists('branch/die-please')
37
40
os.mkdir('no-die-please/child')
39
clean_tree('branch', unknown=True, no_prompt=True)
42
clean_tree('branch', unknown=True)
40
43
assert os.path.exists('no-die-please')
41
44
assert os.path.exists('no-die-please/child')
52
55
file('branch/file.BASE', 'wb').write('contents')
55
self.assertEqual(len(list(iter_deletables(tree, unknown=True))), 1)
56
file('branch/file', 'wb').write('contents')
57
file('branch/file~', 'wb').write('contents')
58
file('branch/file.pyc', 'wb').write('contents')
60
dels = sorted([r for a,r in iter_deletables(tree, unknown=True)])
61
assert sorted(['file', 'file.BASE']) == dels
63
dels = [r for a,r in iter_deletables(tree, detritus=True)]
64
assert sorted(['file~', 'file.BASE']) == dels
66
dels = [r for a,r in iter_deletables(tree, ignored=True)]
67
assert sorted(['file~', 'file.pyc', '.bzrignore']) == dels
69
dels = [r for a,r in iter_deletables(tree, unknown=False)]
56
self.assertEqual(len(list(iter_deletables(tree, unknown=True))), 1)
57
file('branch/file', 'wb').write('contents')
58
file('branch/file~', 'wb').write('contents')
59
file('branch/file.pyc', 'wb').write('contents')
61
dels = sorted([r for a,r in iter_deletables(tree, unknown=True)])
62
assert sorted(['file', 'file.BASE']) == dels
64
dels = [r for a,r in iter_deletables(tree, detritus=True)]
65
assert sorted(['file~', 'file.BASE']) == dels
67
dels = [r for a,r in iter_deletables(tree, ignored=True)]
68
assert sorted(['file~', 'file.pyc', '.bzrignore']) == dels
70
dels = [r for a,r in iter_deletables(tree, unknown=False)]
75
74
return makeSuite(TestCleanTree)