Example #1
0
def isolate_test_cases(
    cmd, test_cases, jobs, isolated_file, isolate_file,
    root_dir, reldir, variables):
  assert os.path.isabs(root_dir) and os.path.isdir(root_dir), root_dir

  logname = isolated_file + '.log'
  basename = isolated_file.rsplit('.', 1)[0]
  cwd_dir = os.path.join(root_dir, reldir)
  # Do the actual tracing.
  results = trace_test_cases.trace_test_cases(
      cmd, cwd_dir, test_cases, jobs, logname)

  api = trace_inputs.get_api()
  logs = dict(
      (i.pop('trace'), i)
      for i in api.parse_log(logname, isolate.chromium_default_blacklist, None))
  exception = None
  try:
    inputs = []
    for items in results:
      item = items[-1]
      assert item['valid']
      # Load the results;
      log_dict = logs[item['tracename']]
      if log_dict.get('exception'):
        exception = exception or log_dict['exception']
        logging.error('Got exception: %s', exception)
        continue
      files = log_dict['results'].strip_root(root_dir).files
      tracked, touched = isolate.split_touched(files)
      value = isolate.generate_isolate(
          tracked,
          [],
          touched,
          root_dir,
          variables,
          reldir)
      # item['test_case'] could be an invalid file name.
      out = basename + '.' + item['tracename'] + '.isolate'
      with open(out, 'w') as f:
        isolate.pretty_print(value, f)
      inputs.append(out)

    # Merges back. Note that it is possible to blow up the command line
    # argument length here but writing the files is still useful. Convert to
    # importing the module instead if necessary.
    merge_cmd = [
      sys.executable,
      os.path.join(BASE_DIR, 'isolate_merge.py'),
      isolate_file,
      '-o', isolate_file,
    ]
    merge_cmd.extend(inputs)
    logging.info(merge_cmd)
    proc = subprocess.Popen(merge_cmd)
    proc.communicate()
    return proc.returncode
  finally:
    if exception:
      raise exception[0], exception[1], exception[2]
Example #2
0
def isolate_test_cases(cmd, test_cases, jobs, isolated_file, isolate_file,
                       root_dir, reldir, variables):
    assert os.path.isabs(root_dir) and os.path.isdir(root_dir), root_dir

    logname = isolated_file + '.log'
    basename = isolated_file.rsplit('.', 1)[0]
    cwd_dir = os.path.join(root_dir, reldir)
    # Do the actual tracing.
    results = trace_test_cases.trace_test_cases(cmd, cwd_dir, test_cases, jobs,
                                                logname)

    api = trace_inputs.get_api()
    logs = dict((i.pop('trace'), i) for i in api.parse_log(
        logname, isolate.chromium_default_blacklist, None))
    exception = None
    try:
        inputs = []
        for items in results:
            item = items[-1]
            assert item['valid']
            # Load the results;
            log_dict = logs[item['tracename']]
            if log_dict.get('exception'):
                exception = exception or log_dict['exception']
                logging.error('Got exception: %s', exception)
                continue
            files = log_dict['results'].strip_root(root_dir).files
            tracked, touched = isolate.split_touched(files)
            value = isolate.generate_isolate(tracked, [], touched, root_dir,
                                             variables, reldir)
            # item['test_case'] could be an invalid file name.
            out = basename + '.' + item['tracename'] + '.isolate'
            with open(out, 'w') as f:
                isolate.pretty_print(value, f)
            inputs.append(out)

        # Merges back. Note that it is possible to blow up the command line
        # argument length here but writing the files is still useful. Convert to
        # importing the module instead if necessary.
        merge_cmd = [
            sys.executable,
            os.path.join(BASE_DIR, 'isolate_merge.py'),
            isolate_file,
            '-o',
            isolate_file,
        ]
        merge_cmd.extend(inputs)
        logging.info(merge_cmd)
        proc = subprocess.Popen(merge_cmd)
        proc.communicate()
        return proc.returncode
    finally:
        if exception:
            raise exception[0], exception[1], exception[2]
 def _isolate_dict_to_string(values):
   buf = cStringIO.StringIO()
   isolate.pretty_print(values, buf)
   return buf.getvalue()
Example #4
0
 def _test_pretty_print_impl(self, value, expected):
   actual = cStringIO.StringIO()
   isolate.pretty_print(value, actual)
   self.assertEqual(expected, actual.getvalue())
 def _isolate_dict_to_string(values):
     buf = cStringIO.StringIO()
     isolate.pretty_print(values, buf)
     return buf.getvalue()