コード例 #1
0
ファイル: gnumbd_test.py プロジェクト: eunchong/infra
  def run(include_log=True):
    stdout = sys.stdout
    stderr = sys.stderr

    if include_log:
      logout = StringIO()
      root_logger = logging.getLogger()
      log_level = root_logger.getEffectiveLevel()
      shandler = logging.StreamHandler(logout)
      shandler.setFormatter(
          logging.Formatter('%(levelname)s: %(message)s'))
      root_logger.addHandler(shandler)
      root_logger.setLevel(logging.INFO)

    success = False
    synthesized_commits = []
    try:
      sys.stderr = sys.stdout = open(os.devnull, 'w')
      local.reify()
      success, synthesized_commits = gnumbd.inner_loop(local, cref, clock)
    except Exception:  # pragma: no cover
      import traceback
      ret.append(traceback.format_exc().splitlines())
    finally:
      sys.stdout = stdout
      sys.stderr = stderr

      if include_log:
        root_logger.removeHandler(shandler)
        root_logger.setLevel(log_level)

        # infra.libs.git2.repo logs this message if the command took longer than
        # 1s to run.  This causes test flakes occasionally.
        log_lines = [x for x in logout.getvalue().splitlines()
                     if 'Finished in ' not in x]
        ret.append({'log output': log_lines})

      ret.append({
        'inner_loop success': success,
        'synthesized_commits': [
          {
            'commit': c.hsh,
            'footers': infra_types.thaw(c.data.footers),
          } for c in synthesized_commits
        ],
      })
コード例 #2
0
    def run(include_log=True):
        stdout = sys.stdout
        stderr = sys.stderr

        if include_log:
            logout = StringIO()
            root_logger = logging.getLogger()
            log_level = root_logger.getEffectiveLevel()
            shandler = logging.StreamHandler(logout)
            shandler.setFormatter(
                logging.Formatter('%(levelname)s: %(message)s'))
            root_logger.addHandler(shandler)
            root_logger.setLevel(logging.INFO)

        success = False
        synthesized_commits = []
        try:
            sys.stderr = sys.stdout = open(os.devnull, 'w')
            local.reify()
            success, synthesized_commits = gnumbd.inner_loop(
                local, cref, clock)
        except Exception:  # pragma: no cover
            import traceback
            ret.append(traceback.format_exc().splitlines())
        finally:
            sys.stdout = stdout
            sys.stderr = stderr

            if include_log:
                root_logger.removeHandler(shandler)
                root_logger.setLevel(log_level)
                ret.append({'log output': logout.getvalue().splitlines()})

            ret.append({
                'inner_loop success':
                success,
                'synthesized_commits': [{
                    'commit':
                    c.hsh,
                    'footers':
                    infra_types.thaw(c.data.footers),
                } for c in synthesized_commits],
            })
コード例 #3
0
 def outer_loop_iteration():
     success, commits = gnumbd.inner_loop(opts.repo, cref)
     all_commits.extend(commits)
     commits_counter.increment_by(len(commits))
     return success
コード例 #4
0
ファイル: __main__.py プロジェクト: nicko96/Chrome-Infra
 def outer_loop_iteration():
   success, commits = gnumbd.inner_loop(opts.repo, cref)
   all_commits.extend(commits)
   commits_counter.increment_by(len(commits))
   return success