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 coverage tool for P3 Analysis Library integration #41

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Pennycook
Copy link
Contributor

@Pennycook Pennycook commented Jan 31, 2024

This PR introduces a new standalone cbicov tool that reads a compilation database and produces JSON that can be read in by the P3 Analysis Library. It is intended to be invoked as below:

cbicov compute -S <source directory> -o <output file> compile_commands.json

MANIFEST.in Outdated Show resolved Hide resolved
@Pennycook Pennycook mentioned this pull request Apr 3, 2024
@Pennycook Pennycook modified the milestones: 1.2.0, 2.0.0 Apr 22, 2024
@Pennycook
Copy link
Contributor Author

@swright87 - I've added -x support, as per your request. It should work the same way as it does in codebasin, but please let me know if you encounter any surprising behavior.

The latest coverage schema from the P3 Analysis Library is 0.3.0,
which requires each entry to provide:

- A file name;
- A unique ID; and
- A simplified line representation (line numbers or regions)

Signed-off-by: John Pennycook <[email protected]>
Previously, a CodeNode could only recover region information in terms
of an extent (start line and end line) which was not sufficient to
export the information required by the new coverage format.

Signed-off-by: John Pennycook <[email protected]>
Invokes internal codebasin functionality to compute coverage information
corresponding to a single compilation database.

Signed-off-by: John Pennycook <[email protected]>
Reimplements the cbicov script as one with support for multiple commands,
exposing the previous default behavior of the cbicov prototype via the
"cbicov compute" command.

The new command also defaults to an output file called "coverage.json", since
this filename was used by 99% of all cbicov invocations in our testing.

Although slightly more complicated, switching to a command-based implementation
will enable us to add more commands related to coverage (e.g., converting
between coverage formats, visualizing coverage, etc) without needing to create
dedicated command-line interfaces for each.

Signed-off-by: John Pennycook <[email protected]>
@Pennycook
Copy link
Contributor Author

Pennycook commented Nov 26, 2024

@laserkelvin, @rfbgo, @douglasjacobsen, @kaanolgu, @tomdeakin, @swright87 - Please take a look at this.

Things had gotten too far behind main to be merged as-is, and rebasing was giving me a headache, which is why I had to force-push. I took the opportunity to clean a few things up and make some improvements based on our experience with the P3 automation framework and anticipated future features. The individual commit messages should explain what's going on, but to summarize:

  • cbicov can now be invoked via either cbicov or python3 -m codebasin.coverage thanks to the magic of pyproject.toml.
  • cbicov -S <source-dir> <database.json> <coverage.json> is now cbicov compute -S <source-dir> -o <coverage.json> database.json. The intent here is to give us flexibility to extend the workflow with commands like cbicov convert (for compatibility with other coverage formats), cbicov show or cbicov report (to help humans interact with the coverage file), etc.
  • I tried to split things out such that there is a cli function accepting an argv, so that we can write tests.

Some specific requests:

  • @rfbgo: Please make sure that your scripts still work if you convert the command style.
  • @laserkelvin: Please review the design and let me know if there's anything that looks weird to you.
  • @swright87: Please try and run this on a few sample codebases and see if the features you requested look good.

In addition to being simpler, we can leverage the indent option to improve the
readability of the output file.

Signed-off-by: John Pennycook <[email protected]>
Previously the test checked that cbicov exported information about every line
in a file, instead of checking that cbicov exported information about every
compiled line.

Signed-off-by: John Pennycook <[email protected]>
cbicov compute runs as-if it was configured with a single platform. Any node
without any associated platform was not compiled, and should be excluded from
the coverage JSON.

Signed-off-by: John Pennycook <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants