[build] Fix for #3365--Add grammar coverage tool. #3511
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.