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

[build] Fix for #3365--Add grammar coverage tool. #3511

Merged
merged 14 commits into from
Jun 22, 2023
Merged

[build] Fix for #3365--Add grammar coverage tool. #3511

merged 14 commits into from
Jun 22, 2023

Conversation

kaby76
Copy link
Contributor

@kaby76 kaby76 commented Jun 5, 2023

This PR fixes #3365.

In this PR, the tool trcover is added, which will produce a nice report of what parser rules are tested. By look at the report, one can find rules that are not tested, then craft tests to complete testing of the entire grammar.

This tool reads the grammar and parses the usual test input. For a grammar, each rule is converted into a minimized NFA. After a parse tree is produced from parsing, the analysis code examines what rules were used during the parse. The tool's output is an annotated version of the grammar file that describes what rules and symbols were parsed. The output is saved as an artifact of the build. Simply navigate to the Action that executed for your PR, and look for "Artifacts" at the top of the page.

To view coverage analysis, click on the "coverage" link to download "coverage.zip". (Here is an example.) Open the zip file and navigate to the "cover.html" file for the grammars you modified. Open the "cover.html" file in a browser to see the annotated grammar. Symbols with a red background indicate symbols that were tested at least once. If the symbol was tested more often, a darker shade of red is used. At the end of the cover.html file is a percentage of the parser rules hit by all tests.

@kaby76 kaby76 marked this pull request as ready for review June 19, 2023 23:52
@teverett
Copy link
Member

@kaby76 thanks!

@teverett teverett merged commit 316eb6d into antlr:master Jun 22, 2023
37 checks passed
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.

[build] Add grammar coverage tool.
3 participants