Rev 4865: (jam) Update a couple tests so that they clean themselves up properly. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Dec 4 15:37:55 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4865 [merge]
revision-id: pqm at pqm.ubuntu.com-20091204153754-fxhnwlf52kbxxczk
parent: pqm at pqm.ubuntu.com-20091204114110-hdb893ip8y4idj1g
parent: john at arbash-meinel.com-20091203203403-cww6ez5nvp616c85
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-12-04 15:37:54 +0000
message:
(jam) Update a couple tests so that they clean themselves up properly.
modified:
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
bzrlib/tests/test_transport.py testtransport.py-20050718175618-e5cdb99f4555ddce
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2009-11-11 06:50:40 +0000
+++ b/bzrlib/tests/test_remote.py 2009-12-03 20:34:03 +0000
@@ -3042,6 +3042,7 @@
local_tree.commit('more local changes are better')
branch = Branch.open(self.get_url('tree3'))
branch.lock_read()
+ self.addCleanup(branch.unlock)
return None, branch
rev_ord, expected_revs = self.get_ordered_revs('1.9', 'unordered',
branch_factory=make_stacked_stacked)
=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py 2009-11-08 23:59:07 +0000
+++ b/bzrlib/tests/test_repository.py 2009-12-03 20:05:29 +0000
@@ -1427,6 +1427,7 @@
index_class=BTreeGraphIndex,
use_chk_index=False)
pack = pack_repo.NewPack(collection)
+ self.addCleanup(pack.abort) # Make sure the write stream gets closed
self.assertIsInstance(pack.revision_index, BTreeBuilder)
self.assertIsInstance(pack.inventory_index, BTreeBuilder)
self.assertIsInstance(pack._hash, type(osutils.md5()))
@@ -1485,6 +1486,7 @@
packer = pack_repo.OptimisingPacker(self.get_pack_collection(),
[], '.test')
new_pack = packer.open_pack()
+ self.addCleanup(new_pack.abort) # ensure cleanup
self.assertIsInstance(new_pack, pack_repo.NewPack)
self.assertTrue(new_pack.revision_index._optimize_for_size)
self.assertTrue(new_pack.inventory_index._optimize_for_size)
=== modified file 'bzrlib/tests/test_transport.py'
--- a/bzrlib/tests/test_transport.py 2009-09-22 04:25:05 +0000
+++ b/bzrlib/tests/test_transport.py 2009-12-03 20:22:57 +0000
@@ -908,6 +908,7 @@
# executes commands, and manage the hooking up of stdin/out/err to the
# SSH channel ourselves. Surely this has already been implemented
# elsewhere?
+ started = []
class StubSSHServer(StubServer):
test = self
@@ -933,10 +934,12 @@
(channel.recv, proc.stdin.write, proc.stdin.close),
(proc.stdout.read, channel.sendall, channel.close),
(proc.stderr.read, channel.sendall_stderr, channel.close)]
+ started.append(proc)
for read, write, close in file_functions:
t = threading.Thread(
target=ferry_bytes, args=(read, write, close))
t.start()
+ started.append(t)
return True
@@ -967,3 +970,13 @@
self.assertEqual(
['%s serve --inet --directory=/ --allow-writes' % bzr_remote_path],
self.command_executed)
+ # Make sure to disconnect, so that the remote process can stop, and we
+ # can cleanup. Then pause the test until everything is shutdown
+ t._client._medium.disconnect()
+ if not started:
+ return
+ # First wait for the subprocess
+ started[0].wait()
+ # And the rest are threads
+ for t in started[1:]:
+ t.join()
More information about the bazaar-commits
mailing list