fix incorrect gcov relative filepath #42
when the gcov file is generated under sub directory, the relative path is still resolved to abs path related to root_dir. The abs path should be resolved related to the CWD.
def process_gcov_data(data_fname, covdata, options): INPUT = open(data_fname,"r") # # Get the filename # line = INPUT.readline() segments=line.split(':',3) if len(segments) != 4 or not segments.lower().strip().endswith('source'): raise RuntimeError('Fatal error parsing gcov file, line 1: \n\t"%s"' % line.rstrip()) currdir = os.getcwd() os.chdir(root_dir) # <==== Following fname will be calculated related to root_dir if sys.version_info >= (2,6): fname = os.path.abspath((segments[-1]).strip()) else: fname = aliases.unalias_path(os.path.abspath((segments[-1]).strip())) os.chdir(currdir)
fix available at kevincai@fcce760.
Test passed with expected result.
The text was updated successfully, but these errors were encountered:
Signed-off-by: Kevin Cai <email@example.com>
OK. I figured out the issue. I wound up not using this pull request, but I committed changes that were very similar. The issue is that gcovr occasionally changes to a different directory, so this fix needed to use the starting directory, not the current directory during gcovr execution.
This issue is finished now. All tests now pass (see gcovr/gcovr/tests/test_gcovr.py).