~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

(jam) Update a couple tests so that they clean themselves up properly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
908
908
        # executes commands, and manage the hooking up of stdin/out/err to the
909
909
        # SSH channel ourselves.  Surely this has already been implemented
910
910
        # elsewhere?
 
911
        started = []
911
912
        class StubSSHServer(StubServer):
912
913
 
913
914
            test = self
933
934
                    (channel.recv, proc.stdin.write, proc.stdin.close),
934
935
                    (proc.stdout.read, channel.sendall, channel.close),
935
936
                    (proc.stderr.read, channel.sendall_stderr, channel.close)]
 
937
                started.append(proc)
936
938
                for read, write, close in file_functions:
937
939
                    t = threading.Thread(
938
940
                        target=ferry_bytes, args=(read, write, close))
939
941
                    t.start()
 
942
                    started.append(t)
940
943
 
941
944
                return True
942
945
 
967
970
        self.assertEqual(
968
971
            ['%s serve --inet --directory=/ --allow-writes' % bzr_remote_path],
969
972
            self.command_executed)
 
973
        # Make sure to disconnect, so that the remote process can stop, and we
 
974
        # can cleanup. Then pause the test until everything is shutdown
 
975
        t._client._medium.disconnect()
 
976
        if not started:
 
977
            return
 
978
        # First wait for the subprocess
 
979
        started[0].wait()
 
980
        # And the rest are threads
 
981
        for t in started[1:]:
 
982
            t.join()