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

coverage flag with more ignore statements #632

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

brettz9
Copy link

@brettz9 brettz9 commented Dec 9, 2019

Fixes #633

Add --coverage/--no-coverage flags and add more ignore statements in generated output

PR type

  • Bug fix (non-breaking change which fixes an issue): no
  • New feature (non-breaking change which adds functionality): yes
  • Breaking change (fix or feature that would cause existing functionality to change): no
  • Documentation change: no

Prerequisites

  • I have read the CONTRIBUTING.md document: yes
  • I have updated the documentation accordingly: yes
  • I have added tests to cover my changes: no

Description

While #546 added a few ignore statements into the generated output, I get the impression the focus of that PR was to add coverage support for maintenance of pegjs itself. This PR is oriented for the users of pegjs so that the generated parsers can be checked with the likes of nyc to ensure that the user's tests avoid a lot of noise from statements which will not or are unlikely to need coverage, while still covering the parser sufficiently.

Some of the ignore statements are intended to suppress coverage warnings for pegjs boilerplate code, e.g., for functions that are only used when there are errors or with caching.

One assumption I have made is that the the else of compile conditions can be ignored (the one ignore statement which is for else rather than next). A lot of noise comes from such statements, and I would expect that a typical coverage scenario would only be interested in checking the presence of the parsed tokens. For projects which don't want this, this PR allows complete disabling of ignore statements.

I may well have missed some areas in which other ignore statements could also be added, and if possible, it would be helpful if someone more intimately familiar with the project could review, but in my testing with our own project, these changes were helpful in cutting out a lot of noise which was distracting from actual missing coverage.

@vercel
Copy link

vercel bot commented Dec 9, 2019

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/peg-js/pegjs/4hgcmifns
✅ Preview: https://pegjs-git-fork-brettz9-coverage.peg-js.now.sh

@Mingun
Copy link
Contributor

Mingun commented Dec 9, 2019

I think, --no-coverage flag is excessive. This is default behaviour and pegjs has no multilevel config files, so only --coverage really is needed

@brettz9
Copy link
Author

brettz9 commented Dec 9, 2019

Sure... I was just doing for parity with the other booleans, but I've added a commit to revert that addition.

@brettz9
Copy link
Author

brettz9 commented Dec 12, 2019

Anything you need from me on this?

@YemSalat
Copy link

@futagoza
Copy link
Member

@YemSalat Tests are usually good, but tbh, in this case, it's probably not needed; the only way to reliably test if this option is working as intended is when NYC/Istanbul is running.

@brettz9 I'm kind of overloaded with my work right now but have been (on my time off) working on a rewrite of the PEG.js library written in TypeScript (was intending to fix a bug in the new plugin system for 0.11 before finally releasing it, but sprawled out of control 😅). I'll leave this open for now so that I can decide later whether to merge this and then pull in the changes with merge conflicts to my WIP branch or add the changes directly in a later commit with reference to this PR.

brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Dec 17, 2019
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Dec 19, 2019
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Dec 25, 2019
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Dec 27, 2019
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Jan 1, 2020
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Jan 6, 2020
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Jan 6, 2020
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Jan 8, 2020
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Jan 10, 2020
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Jan 13, 2020
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Jan 17, 2020
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to jsdoctypeparser/jsdoctypeparser that referenced this pull request Jan 17, 2020
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Jan 25, 2020
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Jan 25, 2020
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/jsdoctypeparser that referenced this pull request Feb 1, 2020
- Testing: Use CLI to ignore unneeded source for improving coverage of pegjs file
brettz9 added a commit to brettz9/esquery that referenced this pull request Mar 1, 2020
… to apply changes by hand as build does not otherwise get `pegjs` binary on the fork)
brettz9 added a commit to brettz9/esquery that referenced this pull request Mar 1, 2020
… to apply changes by hand as build does not otherwise get `pegjs` binary on the fork)
brettz9 added a commit to brettz9/esquery that referenced this pull request Mar 1, 2020
… to apply changes by hand as build does not otherwise get `pegjs` binary on the fork)
@brettz9
Copy link
Author

brettz9 commented Mar 1, 2020

FWIW, in the course of linting another project, I've updated in adding some missing ignores. I'm finding it really invaluable to have something like this, adding missing tests and catching problems as a result. Look forward to your expected next release.

brettz9 added a commit to brettz9/esquery that referenced this pull request Mar 1, 2020
… to apply changes by hand as build does not otherwise get `pegjs` binary on the fork)
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

Successfully merging this pull request may close these issues.

Ignore from coverage more non-grammar statements in generated parsers
4 participants