-
Notifications
You must be signed in to change notification settings - Fork 283
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
Print a warning if root directory contains symlinks. #652
Conversation
Codecov ReportBase: 95.19% // Head: 95.22% // Increases project coverage by
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
Flags with carried forward coverage won't be shown. Click here to find out more.
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. |
gcovr/__main__.py
Outdated
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." | ||
) |
There was a problem hiding this comment.
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:
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.
There was a problem hiding this comment.
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.
Co-authored-by: Lukas Atkinson <opensource@LukasAtkinson.de>
As suggested in #635 print a warning if the root directory contains symlinks.
Closes #635