parameters: (args)
return_statement: return executable, result_file_name
docstring: Merge several sancov files into one.
  
    Called trough multiprocessing pool. The args are expected to unpack to:
      keep: Option if source and intermediate sancov files should be kept.
      coverage_dir: Folder where to find the sancov files.
      executable: Name of the executable whose sancov files should be merged.
      index: A number to be put into the intermediate result file name.
             If None, this is a final result.
      bucket: The list of sancov files to be merged.
    Returns: A tuple with the executable name and the result file name.
docstring_summary: Merge several sancov files into one.
docstring_tokens: Merge several sancov files into one .
function: def merge(args):
    """Merge several sancov files into one.
  
    Called trough multiprocessing pool. The args are expected to unpack to:
      keep: Option if source and intermediate sancov files should be kept.
      coverage_dir: Folder where to find the sancov files.
      executable: Name of the executable whose sancov files should be merged.
      index: A number to be put into the intermediate result file name.
             If None, this is a final result.
      bucket: The list of sancov files to be merged.
    Returns: A tuple with the executable name and the result file name.
    """
    keep, coverage_dir, executable, index, bucket = args
    process = subprocess.Popen(
        [SANCOV_TOOL, 'merge'] + bucket,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        cwd=coverage_dir,
    )
    output, _ = process.communicate()
    assert process.returncode == 0
    if index is not None:
      # This is an intermediate result, add the bucket index to the file name.
      result_file_name = '%s.result.%d.sancov' % (executable, index)
    else:
      # This is the final result without bucket index.
      result_file_name = '%s.result.sancov' % executable
    with open(os.path.join(coverage_dir, result_file_name), "wb") as f:
      f.write(output)
    if not keep:
      for f in bucket:
        os.remove(os.path.join(coverage_dir, f))
    return executable, result_file_name
function_tokens: def merge ( args ) : keep , coverage_dir , executable , index , bucket = args process = subprocess . Popen ( [ SANCOV_TOOL , 'merge' ] + bucket , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = coverage_dir , ) output , _ = process . communicate ( ) assert process . returncode == 0 if index is not None : # This is an intermediate result, add the bucket index to the file name. result_file_name = '%s.result.%d.sancov' % ( executable , index ) else : # This is the final result without bucket index. result_file_name = '%s.result.sancov' % executable with open ( os . path . join ( coverage_dir , result_file_name ) , "wb" ) as f : f . write ( output ) if not keep : for f in bucket : os . remove ( os . path . join ( coverage_dir , f ) ) return executable , result_file_name