~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Vincent Ladeuil
  • Date: 2008-01-29 13:27:36 UTC
  • mto: (3206.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 3207.
  • Revision ID: v.ladeuil+lp@free.fr-20080129132736-nai2jpv02r2wltgc
Fix 16 leaked tmp dirs. Probably indicates a lock handling problem with TransformPreview

* bzrlib/tests/test_transform.py:
(addPreviewCleanup): New method cleaning the TransformPreview
limbdodir leaked by the tests.

* bzrlib/transform.py:
(TransformPreview.__init__): Use a specific prefix for the
limbodir to make leaks more obvious.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib import (
23
23
    errors,
24
24
    generate_ids,
 
25
    osutils,
25
26
    progress,
26
27
    revision as _mod_revision,
27
28
    symbol_versioning,
1832
1833
    def get_empty_preview(self):
1833
1834
        repository = self.make_repository('repo')
1834
1835
        tree = repository.revision_tree(_mod_revision.NULL_REVISION)
1835
 
        return TransformPreview(tree)
 
1836
        preview = TransformPreview(tree)
 
1837
        self.addPreviewCleanup(preview)
 
1838
        return preview
 
1839
 
 
1840
    def addPreviewCleanup(self, preview):
 
1841
        # This probably indicates a problem in the TransformPreview
 
1842
        # API. finalize() can't be called in tests unsing addPreviewCleanup
 
1843
        # because no lock is held.
 
1844
        self.addCleanup(lambda: osutils.rmtree(preview._limbodir))
1836
1845
 
1837
1846
    def test_transform_preview(self):
1838
1847
        revision_tree = self.create_tree()
1839
1848
        preview = TransformPreview(revision_tree)
 
1849
        self.addPreviewCleanup(preview)
1840
1850
 
1841
1851
    def test_transform_preview_tree(self):
1842
1852
        revision_tree = self.create_tree()
1843
1853
        preview = TransformPreview(revision_tree)
 
1854
        self.addPreviewCleanup(preview)
1844
1855
        preview.get_preview_tree()
1845
1856
 
1846
1857
    def test_transform_new_file(self):
1847
1858
        revision_tree = self.create_tree()
1848
1859
        preview = TransformPreview(revision_tree)
 
1860
        self.addPreviewCleanup(preview)
1849
1861
        preview.new_file('file2', preview.root, 'content B\n', 'file2-id')
1850
1862
        preview_tree = preview.get_preview_tree()
1851
1863
        self.assertEqual(preview_tree.kind('file2-id'), 'file')
1855
1867
    def test_diff_preview_tree(self):
1856
1868
        revision_tree = self.create_tree()
1857
1869
        preview = TransformPreview(revision_tree)
 
1870
        self.addPreviewCleanup(preview)
1858
1871
        preview.new_file('file2', preview.root, 'content B\n', 'file2-id')
1859
1872
        preview_tree = preview.get_preview_tree()
1860
1873
        out = StringIO()
1867
1880
    def test_transform_conflicts(self):
1868
1881
        revision_tree = self.create_tree()
1869
1882
        preview = TransformPreview(revision_tree)
 
1883
        self.addPreviewCleanup(preview)
1870
1884
        preview.new_file('a', preview.root, 'content 2')
1871
1885
        resolve_conflicts(preview)
1872
1886
        trans_id = preview.trans_id_file_id('a-id')
1875
1889
    def get_tree_and_preview_tree(self):
1876
1890
        revision_tree = self.create_tree()
1877
1891
        preview = TransformPreview(revision_tree)
 
1892
        self.addPreviewCleanup(preview)
1878
1893
        a_trans_id = preview.trans_id_file_id('a-id')
1879
1894
        preview.delete_contents(a_trans_id)
1880
1895
        preview.create_file('b content', a_trans_id)
1932
1947
    def test_kind(self):
1933
1948
        revision_tree = self.create_tree()
1934
1949
        preview = TransformPreview(revision_tree)
 
1950
        self.addPreviewCleanup(preview)
1935
1951
        preview.new_file('file', preview.root, 'contents', 'file-id')
1936
1952
        preview.new_directory('directory', preview.root, 'dir-id')
1937
1953
        preview_tree = preview.get_preview_tree()