How to use the gcovr.utils.commonpath function in gcovr

To help you get started, we’ve selected a few gcovr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gcovr / gcovr / gcovr / html_generator.py View on Github external
for f in keys:
        cdata = covdata[f]
        filtered_fname = options.root_filter.sub('', f)
        files.append(filtered_fname)
        dirs.append(os.path.dirname(filtered_fname) + os.sep)
        cdata_fname[f] = filtered_fname
        if not details:
            cdata_sourcefile[f] = None
        else:
            cdata_sourcefile[f] = _make_short_sourcename(
                output_file, filtered_fname)

    # Define the common root directory, which may differ from options.root
    # when source files share a common prefix.
    if len(files) > 1:
        commondir = commonpath(files)
        if commondir != '':
            data['DIRECTORY'] = commondir
    else:
        dir_, file_ = os.path.split(filtered_fname)
        if dir_ != '':
            data['DIRECTORY'] = dir_ + os.sep

    nrows = 0
    for f in keys:
        cdata = covdata[f]  # type: FileCoverage
        class_lines = 0
        class_hits = 0
        class_branches = 0
        class_branch_hits = 0
        class_lines, class_hits, _ = cdata.line_coverage()
        b_total, b_hits, _ = cdata.branch_coverage()
github gcovr / gcovr / gcovr / gcov.py View on Github external
def guess_source_file_name_via_aliases(gcovname, currdir, data_fname):
    common_dir = commonpath([data_fname, currdir])
    fname = os.path.realpath(os.path.join(common_dir, gcovname))
    if os.path.exists(fname):
        return fname

    initial_fname = fname

    data_fname_dir = os.path.dirname(data_fname)
    fname = os.path.realpath(os.path.join(data_fname_dir, gcovname))
    if os.path.exists(fname):
        return fname

    # @latk-2018: The original code is *very* insistent
    # on returning the inital guess. Why?
    return initial_fname