8000 Headers containing definitions appear twice in results. by LukiBa · Pull Request #694 · gcovr/gcovr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Headers containing definitions appear twice in results. #694

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 16 commits into from
Feb 15, 2023

Conversation

LukiBa
Copy link
Contributor
@LukiBa LukiBa commented Nov 25, 2022

Issue #329: Headers containing definitions appear once with all lower-case and once with correct case characters in the results under Windows. That leads to wrong code coverage results when using templates.
Implementation of @gmc-devel suggested solution: #329 (comment)

Closes: #329

Headers containing definitions appear once with all lower-case and once correct case characters in the results under Windows.
That leads to wrong code coverage results when using templates.
gcovr/gcov.py Outdated
@@ -184,6 +185,7 @@ def guess_source_file_name(
fname = guess_source_file_name_heuristics(
gcovname, data_fname, currdir, root_dir, starting_dir, obj_dir, gcda_fname
)
fname = str(pathlib.Path(fname).resolve()) # resolves case insensitively of windows paths
Copy link
Member

Choose a reason for hiding this comment

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

This also resolves symlinks which is a big change here.

Copy link
Member

Choose a reason for hiding this comment

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

If os.path.realpath doesn't fix the case we should first replace every usage of os.path with pathlib.Path.

Copy link
Member

Choose a reason for hiding this comment

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

I tried to replace os.path with pathlib.Path but stopped this because there are differences under the hood on Windows which results in Exceptions if used in SCM Clearcase.
Win errors allowed in os.path https://github.com/python/cpython/blob/a87c46eab3c306b1c5b8a072b7b30ac2c50651c0/Lib/ntpath.py#L615-L629 and here the errors allowed in pathlib https://github.com/python/cpython/blob/4710a7589aee48bec9099af308bf5938285ba336/Lib/pathlib.py#L33-L36.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In that case simply using os.path.realpath instead of pathlib.Path().resolve() seam to be the better solution.

Copy link
Member
@Spacetown Spacetown Dec 5, 2022

Choose a reason for hiding this comment

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

But this also resolves the symlinks. I think it would be better fix the casing on our own if the OS is case insensitive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we want to fix the casing by our self, I think to only reasonable soltuion would be to recursivlely resolve the path and check if the case of the child fits the resolved path.
An alternative easy soltuion would be to convert all paths to lower case if the OS is case insensitve.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer the first solution by splitting the path and fix the case for each part.

Copy link
Member
@Spacetown Spacetown left a comment

Choose a reason for hiding this comment

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

I've some suggestions. Is it possible to write a test which triggers the change of the case?

@Spacetown
Copy link
Member

Maybe we can add two gcov files and use the existing files with option --keep instead of compiling the code in our own.

@codecov
Copy link
codecov bot commented Dec 27, 2022

Codecov Report

Base: 95.28% // Head: 95.62% // Increases project coverage by +0.34% 🎉

Coverage data is based on head (3080c3c) compared to base (7273be8).
Patch coverage: 92.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #694      +/-   ##
==========================================
+ Coverage   95.28%   95.62%   +0.34%     
==========================================
  Files          28       28              
  Lines        3773     3843      +70     
  Branches      666      671       +5     
==========================================
+ Hits         3595     3675      +80     
+ Misses         93       91       -2     
+ Partials       85       77       -8     
Flag Coverage Δ
ubuntu-20.04 94.32% <48.00%> (?)
windows-2019 95.22% <86.95%> (-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.64% <ø> (+1.19%) ⬆️
gcovr/utils.py 92.78% <90.47%> (+2.44%) ⬆️
gcovr/gcov.py 78.30% <100.00%> (+0.90%) ⬆️
gcovr/writer/cobertura.py 100.00% <0.00%> (ø)
gcovr/tests/test_config.py 100.00% <0.00%> (ø)
gcovr/exclusions/__init__.py 100.00% <0.00%> (ø)
gcovr/tests/test_gcov_parser.py 100.00% <0.00%> (ø)
gcovr/tests/test_html_generator.py 100.00% <0.00%> (ø)
gcovr/workers.py 98.82% <0.00%> (+0.01%) ⬆️
gcovr/writer/html.py 95.45% <0.00%> (+0.09%) ⬆️
... and 7 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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Spacetown Spacetown changed the title Headers containing definitions appear twice in results. (#329) Headers containing definitions appear twice in results. Feb 5, 2023
@Spacetown Spacetown force-pushed the issue-329 branch 2 times, most recently from fef9f69 to 5d50ef2 Compare February 15, 2023 20:32
@Spacetown Spacetown merged commit cb94612 into gcovr:master Feb 15, 2023
@Spacetown
Copy link
Member

Thank you for working on this.

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.

Headers containing definitions are filtered in out-of-source build
2 participants
0