8000 Print a warning if root directory contains symlinks. by Spacetown · Pull Request #652 · gcovr/gcovr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Print a warning if root directory contains symlinks. #652

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

Merged
merged 7 commits into from
Sep 29, 2022

Conversation

Spacetown
Copy link
Member

As suggested in #635 print a warning if the root directory contains symlinks.

Closes #635

@codecov
Copy link
codecov bot commented Aug 7, 2022

Codecov Report

Base: 95.19% // Head: 95.22% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (ead2e20) compared to base (cd6420c).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #652      +/-   ##
==========================================
+ Coverage   95.19%   95.22%   +0.03%     
==========================================
  Files          24       24              
  Lines        3496     3499       +3     
  Branches      661      662       +1     
==========================================
+ Hits         3328     3332       +4     
  Misses         94       94              
+ Partials       74       73       -1     
Flag Coverage Δ
ubuntu-18.04 93.96% <100.00%> (+0.03%) ⬆️
windows-2019 94.79% <33.33%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
gcovr/tests/test_gcovr.py 97.71% <ø> (ø)
gcovr/__main__.py 94.73% <100.00%> (+0.06%) ⬆️
gcovr/configuration.py 99.68% <0.00%> (+0.31%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines 258 to 262
if options.root_dir != os.path.realpath(options.root_dir):
logger.warning(
"It seems, that your root contains a symlink. This may result in problems. "
"See issue https://github.com/gcovr/gcovr/issues/635."
)
Copy link
Member
@latk latk Aug 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd consider telling the user more explicitly how they can resolve the problem:

Suggested change
if options.root_dir != os.path.realpath(options.root_dir):
logger.warning(
"It seems, that your root contains a symlink. This may result in problems. "
"See issue https://github.com/gcovr/gcovr/issues/635."
)
root_dir_realpath = os.path.realpath(options.root_dir)
if options.root_dir != root_dir_realpath and not options.filters:
logger.warning(
"Your project --root directory seems to contain a symlink. "
"This will EXCLUDE source files in your root directory! "
"To fix this, you may have to add a --filter option:\n"
" --filter=%s\n"
"For details, see https://github.com/gcovr/gcovr/issues/635",
re.escape(root_dir_realpath),
)

Untested, of course. Speaking of which: is there an easy way to test this warning?

I also think that the period . after the URL should be removed to make it easier to click/copy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to add a test. A funny think on Linux, if I open python inside a symlink and running the commands os.path.abspath('.') and os.path.realpath('.'), the output is for both the target of the symlink. If I use the path to the directory instead of '.' the os.abspath doesn't resolve the links.

@Spacetown Spacetown merged commit a747492 into gcovr:master Sep 29, 2022
@Spacetown Spacetown deleted the add_warning_for_symlink_root branch September 29, 2022 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gcovr not scanning files if source files located below virtual path
2 participants
0