~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_import_tariff.py

  • Committer: Andrew Bennetts
  • Date: 2011-05-19 16:24:50 UTC
  • mto: (5927.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 5929.
  • Revision ID: andrew.bennetts@canonical.com-20110519162450-lm3arpb6m4d1m53m
Fix deadlock in TestImportTariffs.test_simple_serve.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
            self.preserved_env_vars[name] = os.environ.get(name)
63
63
        super(TestImportTariffs, self).setUp()
64
64
 
65
 
    def start_bzr_subprocess_with_import_check(self, args):
 
65
    def start_bzr_subprocess_with_import_check(self, args, stderr_file=None):
66
66
        """Run a bzr process and capture the imports.
67
67
 
68
68
        This is fairly expensive because we start a subprocess, so we aim to
187
187
    def test_simple_serve(self):
188
188
        # 'serve' in a default format working tree shouldn't need many modules
189
189
        tree = self.make_branch_and_tree('.')
 
190
        # Capture the bzr serve process' stderr in a file to avoid deadlocks
 
191
        # while the smart client interacts with it.
 
192
        stderr_file = open('bzr-serve.stderr', 'w')
190
193
        process = self.start_bzr_subprocess_with_import_check(['serve',
191
 
            '--inet', '-d', tree.basedir])
 
194
            '--inet', '-d', tree.basedir], stderr_file=stderr_file)
192
195
        url = 'bzr://localhost/'
193
196
        self.permit_url(url)
194
197
        client_medium = medium.SmartSimplePipesClientMedium(
200
203
        process.stdin = None
201
204
        (out, err) = self.finish_bzr_subprocess(process,
202
205
            universal_newlines=False)
 
206
        stderr_file.close()
 
207
        with open('bzr-serve.stderr', 'r') as stderr_file:
 
208
            err = stderr_file.read()
203
209
        self.check_forbidden_modules(err,
204
210
            ['bzrlib.annotate',
205
211
            'bzrlib.atomicfile',