~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
1519
1519
            'BZR_PROGRESS_BAR': None,
1520
1520
            'BZR_LOG': None,
1521
1521
            'BZR_PLUGIN_PATH': None,
 
1522
            'BZR_DISABLE_PLUGINS': None,
 
1523
            'BZR_PLUGINS_AT': None,
1522
1524
            'BZR_CONCURRENCY': None,
1523
1525
            # Make sure that any text ui tests are consistent regardless of
1524
1526
            # the environment the test case is run in; you may want tests that
1671
1673
                unicodestr = log_contents.decode('utf8', 'replace')
1672
1674
                log_contents = unicodestr.encode('utf8')
1673
1675
            if not keep_log_file:
1674
 
                self._log_file.close()
 
1676
                close_attempts = 0
 
1677
                max_close_attempts = 100
 
1678
                first_close_error = None
 
1679
                while close_attempts < max_close_attempts:
 
1680
                    close_attempts += 1
 
1681
                    try:
 
1682
                        self._log_file.close()
 
1683
                    except IOError, ioe:
 
1684
                        if ioe.errno is None:
 
1685
                            # No errno implies 'close() called during
 
1686
                            # concurrent operation on the same file object', so
 
1687
                            # retry.  Probably a thread is trying to write to
 
1688
                            # the log file.
 
1689
                            if first_close_error is None:
 
1690
                                first_close_error = ioe
 
1691
                            continue
 
1692
                        raise
 
1693
                    else:
 
1694
                        break
 
1695
                if close_attempts > 1:
 
1696
                    sys.stderr.write(
 
1697
                        'Unable to close log file on first attempt, '
 
1698
                        'will retry: %s\n' % (first_close_error,))
 
1699
                    if close_attempts == max_close_attempts:
 
1700
                        sys.stderr.write(
 
1701
                            'Unable to close log file after %d attempts.\n'
 
1702
                            % (max_close_attempts,))
1675
1703
                self._log_file = None
1676
1704
                # Permit multiple calls to get_log until we clean it up in
1677
1705
                # finishLogFile
3583
3611
        'bzrlib.tests.commands',
3584
3612
        'bzrlib.tests.per_branch',
3585
3613
        'bzrlib.tests.per_bzrdir',
 
3614
        'bzrlib.tests.per_bzrdir_colo',
3586
3615
        'bzrlib.tests.per_foreign_vcs',
3587
3616
        'bzrlib.tests.per_interrepository',
3588
3617
        'bzrlib.tests.per_intertree',