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

Use os.path.commonpath in guess_source_filename #299

Closed
clynamen opened this issue Mar 14, 2019 · 1 comment
Labels

Comments

@clynamen
Copy link

@clynamen clynamen commented Mar 14, 2019

common_dir = os.path.commonprefix([data_fname, currdir])

I ran into an error where not-existing filename where generated due to common prefix. Indeed this function will return an invalid directory in this case

data_fname=/cygdrive/my_source/my_main.cpp
currdir=/cygdrive/my_build

it will result in directory /cygdrive/my due to the fact that commonprefix return the prefix string instead of the prefix path

I think the proper function to use here is
https://docs.python.org/3/library/os.path.html#os.path.commonpath

A similar issue caused #52

@latk

This comment has been minimized.

Copy link
Member

@latk latk commented Mar 14, 2019

Thank you for finding that! Historically, the problem is that gcovr still supports Python 2.7 which doesn't have a commonpath() function in the standard library, we therefore have a custom implementation in the gcovr.util module.

I'll fix this right away!

@latk latk added the Type: Bug label Mar 14, 2019
@latk latk closed this in 026b00c Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.