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

Improve programmatic access #311

Closed
bracco23 opened this issue May 21, 2019 · 5 comments
Closed

Improve programmatic access #311

bracco23 opened this issue May 21, 2019 · 5 comments

Comments

@bracco23
Copy link

I'm working on using gcovr to parse output on our unit tests.

Since invocation of gcovr from the command line is slow, I opted to import all the relevant processing data from a custom script which basically execute tests, collects gcda files and invokes gcov on them in the right folder, uses gcovr parsing functionalities to print html and xml outputs.

What I noticed is that the different functions rely heavily on the options passed to the main script, so much that I had to recreate the object and customize.

It would be much better to not use the command line options in any module different than the main one so that other modules can use them without having to rely on the same object.

For example, print_html_report takes covdata and options as input. It is cleaner to pass the flags as separate parameters or as a custom HTMLOptions object, so that it can be used by other scripts in a much simpler way.

@latk
Copy link
Member

latk commented May 21, 2019

I agree, feel free to refactor. If you figure out a sensible interface that will work for all generators, I'd be open to exposing that as an API for Python scripts (right now, I consider everything internal/private).

But please be warned that I'm seriously behind on reviewing & merging PRs

@chenlijun99
Copy link

@Spacetown Hi. I see that you closed this issue as completed in March 19. However I couldn't find any documentation about programmatic APIs for gcovr. I tried also to look through some commits near March 19 as well as read the changelog of gcovr 5.1 (released in March 26), but couldn't find anything.
Did I misinterpret the "closed as completed" and in reality no API has been exposed?

@latk
Copy link
Member

latk commented Sep 14, 2022

@chenlijun99 Correct, no API has been exposed. At this time, gcovr only supports interaction via its command line interface. But you can “extend” coverage processing by manipulating the JSON output format. For example, if you want to customize coverage exclusion processing, you could do:

# 1. collect coverage data
gcovr --json raw-coverage.json

# 2. modify the JSON file as needed
./your-custom-filter <raw-coverage.json >processed-coverage.json

# 3. use gcovr to output a coverage report
gcovr -a processed-coverage.json --html-details report.html

At the time when this issue was closed, GitHub did not distinguish between “close as completed” and “close as not planned”. That feature was introduced two months later.

@chenlijun99
Copy link

@latk Thanks for the suggestion! Thanks also for the GitHub history lesson 😄 !

@Spacetown
Copy link
Member

Good to know that we can now close as not planned.

@Spacetown Spacetown closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants