Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix incorrect gcov relative filepath #42

Merged
merged 2 commits into from Jul 3, 2014
Merged

fix incorrect gcov relative filepath #42

merged 2 commits into from Jul 3, 2014

Conversation

@kevincai
Copy link

@kevincai kevincai commented Mar 21, 2014

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.

code snippet:

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[2].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.

Kevin Cai added 2 commits Mar 21, 2014
Signed-off-by: Kevin Cai <kevinc@mozy.com>
* while processing the gcov data, the gcov filepath should
  be calculated related to the getcwd(), not the root dir

Signed-off-by: Kevin Cai <kevinc@mozy.com>
@ejurado
Copy link

@ejurado ejurado commented Mar 26, 2014

Excellent, hopefully it will get into 3.2!

whart222 added a commit that referenced this issue Jul 3, 2014
fix incorrect gcov relative filepath
@whart222 whart222 merged commit 3d5ac05 into gcovr:master Jul 3, 2014
@whart222 whart222 added this to the Gcovr 3.2 milestone Jul 3, 2014
@whart222
Copy link
Member

@whart222 whart222 commented Jul 3, 2014

This didn't pass the gcovr tests. I'm still trying to figure out whether this pull request makes sense. A motivating example would help.

@kevincai
Copy link
Author

@kevincai kevincai commented Jul 4, 2014

where can i find the tests? I can spend sometime to investigate what breaks.

whart222 added a commit that referenced this issue Jul 4, 2014
Changing the simple text output to have a more detailed header.

Using the starting directory when setting the gcov path.
This resolves issue #42, but it's more explicit that the starting
directory is used to process gcov filenames.
@whart222
Copy link
Member

@whart222 whart222 commented Jul 4, 2014

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).

@kevincai
Copy link
Author

@kevincai kevincai commented Jul 7, 2014

Thanks for fixing this!

JamesReynolds pushed a commit to JamesReynolds/gcovr that referenced this issue Mar 8, 2018
fix incorrect gcov relative filepath
JamesReynolds pushed a commit to JamesReynolds/gcovr that referenced this issue Mar 8, 2018
Changing the simple text output to have a more detailed header.

Using the starting directory when setting the gcov path.
This resolves issue gcovr#42, but it's more explicit that the starting
directory is used to process gcov filenames.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants