8000 Support of toml configuration by Spacetown · Pull Request #881 · gcovr/gcovr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support of toml configuration #881

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 11 commits into from
Feb 18, 2024

Conversation

Spacetown
Copy link
Member
@Spacetown Spacetown commented Feb 6, 2024

This PR adds initial support for a TOML configuration. Following configuration files are searched in the root directory, the first one which is found is used:

  • gcovr.cfg (legacy configuration format)
  • gcovr.toml
  • pyproject.toml

If a TOML file is found the section gcovr is searched which can also be a list. If no section is found the file is ignored.

I prefer first to do a review on the code and if this is done I'll start with the documentation.

Closes #875

@Spacetown Spacetown added Type: Enhancement cli relating to the command line interface or the config system labels Feb 6, 2024
@Spacetown Spacetown added this to the Upcoming release milestone Feb 6, 2024
@LecrisUT
Copy link
LecrisUT commented Feb 6, 2024

I will look into it in more detail later in the week, but 2 quick unrelated notes:

  • are there plans to migrate to pathlib over os.path?
  • __future__.annotations is used, so any plans to drop deprecated typing.Dict, etc.?

For the code itself something feels off with how pyproject.toml is parsed identically to gcovr.toml according to the tests, but I need to look more carefully at the implementation

Copy link
Member
@latk latk left a comment

Choose a reason for hiding this comment

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

This is a big/important feature, and that makes me a bit nervous.

I'm on board with the main ideas of this PR:

  1. support a gcovr.toml file
  2. handle multi-value options by flattening a toml list into one ConfigEntry per element

I am less certain about the other stuff – multiple configurations, pyproject.toml support. See the following comments for detailed discussion.

@Spacetown
Copy link
Member Author
Spacetown commented Feb 7, 2024

I will look into it in more detail later in the week, but 2 quick unrelated notes:

No problem.

  • are there plans to migrate to pathlib over os.path?

I won't do this in the near future because in my company we use SCM Clearcase and the path resolution is not working there. I've already provided a patch for os.path to work in Clearcase but need to raise a PR for path lib to ignore the same errors in path resolution on Windows as os.path is doing.

  • __future__.annotations is used, so any plans to drop deprecated typing.Dict, etc.?

dict supports [] since 3.9 but we still support 3.8.

For the code itself something feels off with how pyproject.toml is parsed identically to gcovr.toml according to the tests, but I need to look more carefully at the implementation

This is changed with the next push as suggested by @latk:

  • gcovr.toml doesn't use sections.
  • pyproject.toml uses tool.gcovr as section.

- In pyproject.toml `tool.gcovr` is used.
- In gcovr.toml no section is used.
@Spacetown Spacetown force-pushed the support_of_toml_configuration branch from 10cfafd to 46c6cf5 Compare February 11, 2024 19:52
The config parsing is done with iterators and the needs to be handled
while the file is opened (inside the `with` statement).
@Spacetown Spacetown force-pushed the support_of_toml_configuration branch from 46c6cf5 to 27273fb Compare February 11, 2024 20:54
Copy link
codecov bot commented Feb 11, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (023dec1) 95.33% compared to head (10555e1) 95.33%.

Files Patch % Lines
gcovr/__main__.py 96.55% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #881   +/-   ##
=======================================
  Coverage   95.33%   95.33%           
=======================================
  Files          54       54           
  Lines        4544     4566   +22     
  Branches      893      904   +11     
=======================================
+ Hits         4332     4353   +21     
  Misses        130      130           
- Partials       82       83    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Spacetown
Copy link
Member Author

@LecrisUT Any updates here?

Copy link
@LecrisUT LecrisUT left a comment

Choose a reason for hiding this comment

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

Thanks. @latk covered the concerns I had. I looked over the new implementation and it all looks fine now

@Spacetown Spacetown merged commit 3e5a922 into gcovr:main Feb 18, 2024
@Spacetown Spacetown deleted the support_of_toml_configuration branch February 18, 2024 19:32
@Spacetown Spacetown removed this from the Upcoming release milestone Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli relating to the command line interface or the config system Type: Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Read configuration from pyproject.toml
3 participants
0