testing/merge_scripts/standard_gtest_merge.py
def load_shard_json(index, task_id, jsons_to_merge):
  """Reads JSON output of the specified shard.

  Args:
    output_dir: The directory in which to look for the JSON output to load.
    index: The index of the shard to load data for, this is for old api.
    task_id: The directory of the shard to load data for, this is for new api.

  Returns: A tuple containing:
    * The contents of path, deserialized into a python object.
    * An error string.
    (exactly one of the tuple elements will be non-None).
  """
  # 'output.json' is set in swarming/api.py, gtest_task method.
  matching_json_files = [
      j for j in jsons_to_merge
      if (os.path.basename(j) == 'output.json' and
          (os.path.basename(os.path.dirname(j)) == str(index) or
           os.path.basename(os.path.dirname(j)) == task_id))]

  if not matching_json_files:
    print('shard %s test output missing' % index, file=sys.stderr)
    return (None, 'shard %s test output was missing' % index)
  elif len(matching_json_files) > 1:
    print('duplicate test output for shard %s' % index, file=sys.stderr)
    return (None, 'shard %s test output was duplicated' % index)

  path = matching_json_files[0]

  try:
    filesize = os.stat(path).st_size
    if filesize > OUTPUT_JSON_SIZE_LIMIT:
      print('output.json is %d bytes. Max size is %d' % (
           filesize, OUTPUT_JSON_SIZE_LIMIT), file=sys.stderr)
      return (None, 'shard %s test output exceeded the size limit' % index)

    with open(path) as f:
      return (json.load(f), None)
  except (IOError, ValueError, OSError) as e:
    print('Missing or invalid gtest JSON file: %s' % path, file=sys.stderr)
    print('%s: %s' % (type(e).__name__, e), file=sys.stderr)

    return (None, 'shard %s test output was missing or invalid' % index)
Reads JSON output of the specified shard.

  Args:
    output_dir: The directory in which to look for the JSON output to load.
    index: The index of the shard to load data for, this is for old api.
    task_id: The directory of the shard to load data for, this is for new api.

  Returns: A tuple containing:
    * The contents of path, deserialized into a python object.
    * An error string.
    (exactly one of the tuple elements will be non-None).
  
Reads JSON output of the specified shard.
Reads JSON output of the specified shard .
def load_shard_json(index, task_id, jsons_to_merge):
  matching_json_files = [
      j for j in jsons_to_merge
      if (os.path.basename(j) == 'output.json' and
          (os.path.basename(os.path.dirname(j)) == str(index) or
           os.path.basename(os.path.dirname(j)) == task_id))]
  if not matching_json_files:
    print('shard %s test output missing' % index, file=sys.stderr)
    return (None, 'shard %s test output was missing' % index)
  elif len(matching_json_files) > 1:
    print('duplicate test output for shard %s' % index, file=sys.stderr)
    return (None, 'shard %s test output was duplicated' % index)
  path = matching_json_files[0]
  try:
    filesize = os.stat(path).st_size
    if filesize > OUTPUT_JSON_SIZE_LIMIT:
      print('output.json is %d bytes. Max size is %d' % (
           filesize, OUTPUT_JSON_SIZE_LIMIT), file=sys.stderr)
      return (None, 'shard %s test output exceeded the size limit' % index)
    with open(path) as f:
      return (json.load(f), None)
  except (IOError, ValueError, OSError) as e:
    print('Missing or invalid gtest JSON file: %s' % path, file=sys.stderr)
    print('%s: %s' % (type(e).__name__, e), file=sys.stderr)
    return (None, 'shard %s test output was missing or invalid' % index)
def load_shard_json ( index , task_id , jsons_to_merge ) : matching_json_files = [ j for j in jsons_to_merge if ( os . path . basename ( j ) == 'output.json' and ( os . path . basename ( os . path . dirname ( j ) ) == str ( index ) or os . path . basename ( os . path . dirname ( j ) ) == task_id ) ) ] if not matching_json_files : print ( 'shard %s test output missing' % index , file = sys . stderr ) return ( None , 'shard %s test output was missing' % index ) elif len ( matching_json_files ) > 1 : print ( 'duplicate test output for shard %s' % index , file = sys . stderr ) return ( None , 'shard %s test output was duplicated' % index ) path = matching_json_files [ 0 ] try : filesize = os . stat ( path ) . st_size if filesize > OUTPUT_JSON_SIZE_LIMIT : print ( 'output.json is %d bytes. Max size is %d' % ( filesize , OUTPUT_JSON_SIZE_LIMIT ) , file = sys . stderr ) return ( None , 'shard %s test output exceeded the size limit' % index ) with open ( path ) as f : return ( json . load ( f ) , None ) except ( IOError , ValueError , OSError ) as e : print ( 'Missing or invalid gtest JSON file: %s' % path , file = sys . stderr ) print ( '%s: %s' % ( type ( e ) . __name__ , e ) , file = sys . stderr ) return ( None , 'shard %s test output was missing or invalid' % index )
Reads JSON output of the specified shard.
Reads JSON output of the specified shard .
"""Reads JSON output of the specified shard.

  Args:
    output_dir: The directory in which to look for the JSON output to load.
    index: The index of the shard to load data for, this is for old api.
    task_id: The directory of the shard to load data for, this is for new api.

  Returns: A tuple containing:
    * The contents of path, deserialized into a python object.
    * An error string.
    (exactly one of the tuple elements will be non-None).
  """ # 'output.json' is set in swarming/api.py, gtest_task method.
index
The index of the shard to load data for, this is for old api.
The index of the shard to load data for this is for old api .
task_id
The directory of the shard to load data for, this is for new api.
The directory of the shard to load data for this is for new api .
jsons_to_merge
output_dir
The directory in which to look for the JSON output to load.
The directory in which to look for the JSON output to load .