Rev 4670: Fix all known selftest leaks in /tmp in http://bazaar.launchpad.net/~vila/bzr/integration

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Sep 3 18:04:34 BST 2009


At http://bazaar.launchpad.net/~vila/bzr/integration

------------------------------------------------------------
revno: 4670 [merge]
revision-id: v.ladeuil+lp at free.fr-20090903170421-52olt3uskrxlu1br
parent: pqm at pqm.ubuntu.com-20090903150454-mm3xdxw6jq6mml5l
parent: v.ladeuil+lp at free.fr-20090903081023-jxa59liaax1k5ba4
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: integration
timestamp: Thu 2009-09-03 19:04:21 +0200
message:
  Fix all known selftest leaks in /tmp
modified:
  bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
  bzrlib/tests/test_mail_client.py test_mail_client.py-20070809192806-vuxt3t19srtpjpdn-2
  bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
  bzrlib/tests/test_shelf.py     test_prepare_shelf.p-20081005181341-n74qe6gu1e65ad4v-2
  bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
-------------- next part --------------
=== modified file 'bzrlib/mail_client.py'
--- a/bzrlib/mail_client.py	2009-06-10 03:56:49 +0000
+++ b/bzrlib/mail_client.py	2009-09-02 08:26:27 +0000
@@ -424,6 +424,10 @@
 
     _client_commands = ['emacsclient']
 
+    def __init__(self, config):
+        super(EmacsMail, self).__init__(config)
+        self.elisp_tmp_file = None
+
     def _prepare_send_function(self):
         """Write our wrapper function into a temporary file.
 
@@ -500,6 +504,7 @@
         if attach_path is not None:
             # Do not create a file if there is no attachment
             elisp = self._prepare_send_function()
+            self.elisp_tmp_file = elisp
             lmmform = '(load "%s")' % elisp
             mmform  = '(bzr-add-mime-att "%s")' % \
                 self._encode_path(attach_path, 'attachment')

=== modified file 'bzrlib/tests/test_mail_client.py'
--- a/bzrlib/tests/test_mail_client.py	2009-06-10 03:56:49 +0000
+++ b/bzrlib/tests/test_mail_client.py	2009-09-02 08:26:27 +0000
@@ -97,6 +97,8 @@
         # We won't be able to know the temporary file name at this stage
         # so we can't raise an assertion with assertEqual
         cmdline = eclient._get_compose_commandline(None, None, 'file%')
+        if eclient.elisp_tmp_file is not None:
+            self.addCleanup(osutils.delete_any, eclient.elisp_tmp_file)
         commandline = ' '.join(cmdline)
         self.assertContainsRe(commandline, '--eval')
         self.assertContainsRe(commandline, '(compose-mail nil nil)')
@@ -107,6 +109,8 @@
         eclient = mail_client.EmacsMail(None)
         commandline = eclient._get_compose_commandline(u'jrandom at example.org',
             u'Hi there!', u'file%')
+        if eclient.elisp_tmp_file is not None:
+            self.addCleanup(osutils.delete_any, eclient.elisp_tmp_file)
         for item in commandline:
             self.assertFalse(isinstance(item, unicode),
                 'Command-line item %r is unicode!' % item)

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2009-08-26 23:25:28 +0000
+++ b/bzrlib/tests/test_selftest.py	2009-09-03 08:10:23 +0000
@@ -1493,6 +1493,7 @@
         outer_test = TestTestCase("outer_child")
         result = self.make_test_result()
         outer_test.run(result)
+        self.addCleanup(osutils.delete_any, outer_test._log_file_name)
         self.assertEqual(original_trace, bzrlib.trace._trace_file)
 
     def method_that_times_a_bit_twice(self):

=== modified file 'bzrlib/tests/test_shelf.py'
--- a/bzrlib/tests/test_shelf.py	2009-08-28 05:00:33 +0000
+++ b/bzrlib/tests/test_shelf.py	2009-09-03 17:04:21 +0000
@@ -503,6 +503,7 @@
             shelf_file.seek(0)
             unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file)
             unshelver.make_merger().do_merge()
+            self.addCleanup(unshelver.finalize)
             self.assertFileEqual('bar', 'tree/foo')
         finally:
             shelf_file.close()
@@ -526,6 +527,7 @@
         self.build_tree_contents([('tree/foo', 'z\na\nb\nc\n')])
         shelf_file.seek(0)
         unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file)
+        self.addCleanup(unshelver.finalize)
         unshelver.make_merger().do_merge()
         self.assertFileEqual('z\na\nb\nd\n', 'tree/foo')
 
@@ -554,6 +556,7 @@
         self.assertFileEqual('baz', 'tree/foo/bar')
         shelf_file.seek(0)
         unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file)
+        self.addCleanup(unshelver.finalize)
         unshelver.make_merger().do_merge()
         self.assertFalse('foo-id' in tree)
         self.assertFalse('bar-id' in tree)
@@ -699,6 +702,7 @@
         shelf_id = shelf_manager.shelve_changes(creator)
         self.failIfExists('tree/foo')
         unshelver = shelf_manager.get_unshelver(shelf_id)
+        self.addCleanup(unshelver.finalize)
         unshelver.make_merger().do_merge()
         self.assertFileEqual('bar', 'tree/foo')
 

=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py	2009-08-13 01:33:15 +0000
+++ b/bzrlib/tests/test_transform.py	2009-09-02 09:07:24 +0000
@@ -1916,6 +1916,7 @@
         branch.lock_write()
         self.addCleanup(branch.unlock)
         tt = TransformPreview(branch.basis_tree())
+        self.addCleanup(tt.finalize)
         tt.new_directory('', ROOT_PARENT, 'TREE_ROOT')
         rev = tt.commit(branch, 'my message')
         self.assertEqual([], branch.basis_tree().get_parent_ids())
@@ -1927,6 +1928,7 @@
         branch.lock_write()
         self.addCleanup(branch.unlock)
         tt = TransformPreview(branch.basis_tree())
+        self.addCleanup(tt.finalize)
         e = self.assertRaises(ValueError, tt.commit, branch,
                           'my message', ['rev1b-id'])
         self.assertEqual('Cannot supply merge parents for first commit.',
@@ -1957,6 +1959,7 @@
         tt.new_file('file', tt.root, 'contents', 'file-id')
         tt.commit(branch, 'message', strict=True)
         tt = TransformPreview(branch.basis_tree())
+        self.addCleanup(tt.finalize)
         trans_id = tt.trans_id_file_id('file-id')
         tt.delete_contents(trans_id)
         tt.create_file('contents', trans_id)



More information about the bazaar-commits mailing list