~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-13 09:29:44 UTC
  • mfrom: (4738.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20091013092944-37m2zia1k83g061y
(vila) Clearer thread leaks reports

Show diffs side-by-side

added added

removed removed

Lines of Context:
222
222
                '%s is leaking threads among %d leaking tests.\n' % (
223
223
                TestCase._first_thread_leaker_id,
224
224
                TestCase._leaking_threads_tests))
 
225
            # We don't report the main thread as an active one.
 
226
            self.stream.write(
 
227
                '%d non-main threads were left active in the end.\n'
 
228
                % (TestCase._active_threads - 1))
225
229
 
226
230
    def _extractBenchmarkTime(self, testCase):
227
231
        """Add a benchmark time for the current test case."""
846
850
        active = threading.activeCount()
847
851
        leaked_threads = active - TestCase._active_threads
848
852
        TestCase._active_threads = active
849
 
        if leaked_threads:
 
853
        # If some tests make the number of threads *decrease*, we'll consider
 
854
        # that they are just observing old threads dieing, not agressively kill
 
855
        # random threads. So we don't report these tests as leaking. The risk
 
856
        # is that we have false positives that way (the test see 2 threads
 
857
        # going away but leak one) but it seems less likely than the actual
 
858
        # false positives (the test see threads going away and does not leak).
 
859
        if leaked_threads > 0:
850
860
            TestCase._leaking_threads_tests += 1
851
861
            if TestCase._first_thread_leaker_id is None:
852
862
                TestCase._first_thread_leaker_id = self.id()