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

Conversation

Projects
None yet
3 participants
@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 some commits Mar 21, 2014

Kevin Cai
Merge remote branch 'nschum/fix-argument-type' into master
Signed-off-by: Kevin Cai <kevinc@mozy.com>
Kevin Cai
fix incorrect chdir while processing gcov data
* 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

This comment has been minimized.

ejurado commented Mar 26, 2014

Excellent, hopefully it will get into 3.2!

whart222 added a commit that referenced this pull request Jul 3, 2014

Merge pull request #42 from kevincai/master
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

This comment has been minimized.

Member

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

This comment has been minimized.

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 pull request Jul 4, 2014

Two updates
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

This comment has been minimized.

Member

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

This comment has been minimized.

kevincai commented Jul 7, 2014

Thanks for fixing this!

JamesReynolds pushed a commit to JamesReynolds/gcovr that referenced this pull request Mar 8, 2018

Merge pull request gcovr#42 from kevincai/master
fix incorrect gcov relative filepath

JamesReynolds pushed a commit to JamesReynolds/gcovr that referenced this pull request Mar 8, 2018

Two updates
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