~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/clean_tree.py

  • Committer: Aaron Bentley
  • Date: 2006-06-13 02:31:28 UTC
  • mfrom: (0.1.119 shelf)
  • Revision ID: aaron.bentley@utoronto.ca-20060613023128-20f2ff3a212a6ea2
Pull in latest shelf stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from unittest import makeSuite
21
21
 
22
22
from bzrlib.bzrdir import BzrDir
 
23
try:
 
24
    from bzrlib.plugins.bzrtools.clean_tree import clean_tree, iter_deletables
 
25
except ImportError:
 
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
25
29
 
26
 
from bzrlib.plugins.bzrtools.clean_tree import clean_tree, iter_deletables
27
30
 
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')
38
41
 
39
 
        clean_tree('branch', unknown=True)
 
42
        clean_tree('branch')
40
43
        assert os.path.exists('no-die-please')
41
44
        assert os.path.exists('no-die-please/child')
42
45
 
44
47
        """Files are selected for deletion appropriately"""
45
48
        os.mkdir('branch')
46
49
        tree = BzrDir.create_standalone_workingtree('branch')
47
 
        f = file('branch/.bzrignore', 'wb')
48
 
        try:
49
 
            f.write('*~\n*.pyc\n.bzrignore\n')
50
 
        finally:
51
 
            f.close()
52
50
        file('branch/file.BASE', 'wb').write('contents')
53
 
        tree.lock_write()
54
 
        try:
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')
59
 
 
60
 
            dels = sorted([r for a,r in iter_deletables(tree, unknown=True)])
61
 
            assert sorted(['file', 'file.BASE']) == dels
62
 
 
63
 
            dels = [r for a,r in iter_deletables(tree, detritus=True)]
64
 
            assert sorted(['file~', 'file.BASE']) == dels
65
 
 
66
 
            dels = [r for a,r in iter_deletables(tree, ignored=True)]
67
 
            assert sorted(['file~', 'file.pyc', '.bzrignore']) == dels
68
 
 
69
 
            dels = [r for a,r in iter_deletables(tree, unknown=False)]
70
 
            assert [] == dels
71
 
        finally:
72
 
            tree.unlock()
 
51
        self.assertEqual(len(list(iter_deletables(tree))), 1)
 
52
        file('branch/file~', 'wb').write('contents')
 
53
        file('branch/file.pyc', 'wb').write('contents')
 
54
        dels = [r for a,r in iter_deletables(tree)]
 
55
        assert 'file~' not in dels
 
56
        assert 'file.pyc' not in dels
 
57
        dels = [r for a,r in iter_deletables(tree, detritus=True)]
 
58
        assert 'file~' in dels
 
59
        assert 'file.pyc' not in dels
 
60
        dels = [r for a,r in iter_deletables(tree, ignored=True)]
 
61
        assert 'file~' in dels
 
62
        assert 'file.BASE' in dels
 
63
        assert 'file.pyc' in dels
 
64
        dels = [r for a,r in iter_deletables(tree, unknown=False)]
 
65
        assert 'file.BASE' not in dels
73
66
 
74
67
def test_suite():
75
68
    return makeSuite(TestCleanTree)