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

Run code coverage for a single file #23612

Closed
wnordmann opened this issue Oct 12, 2018 · 10 comments
Closed

Run code coverage for a single file #23612

wnordmann opened this issue Oct 12, 2018 · 10 comments
Labels
coverage Issues and PRs related to native coverage support. test Issues and PRs related to the tests.

Comments

@wnordmann
Copy link

The directions for running code coverage do not detail how to run coverage for a single file. It would improve performance when writing tests with the goal of improving coverage to be able to test one file at a time.
https://github.com/nodejs/node/blob/master/doc/guides/contributing/pull-requests.md#test-coverage

@ChALkeR ChALkeR added test Issues and PRs related to the tests. coverage Issues and PRs related to native coverage support. labels Oct 12, 2018
@addaleax
Copy link
Member

/cc @bcoe

@mhdawson
Copy link
Member

@wnordmann if I understand correctly you want to just get the coverage provided by running a single test?

@wnordmann
Copy link
Author

@mhdawson correct. The main goal is a document update allowing for quick testing / verifying of code coverage.

@mhdawson
Copy link
Member

mhdawson commented Oct 29, 2018

@wnordmann can you try out this branch https://github.com/mhdawson/io.js/tree/cov-single

It has an additional target coverage-update which might be what you want.

You would use as follows

  1. run make coverage normally
  2. Make your updates to specific tests, run those specific tests
  3. run coverage-update
  4. Review the updated coverage.

I think it would update overall coverage based on only the tests you have run.

@mhdawson
Copy link
Member

If that works for you I'll PR it in.

@bcoe
Copy link
Contributor

bcoe commented Oct 29, 2018

@mhdawson @wnordmann sorry for dropping this thread on the floor; Not going to lie, I was making an effort to get #23941 over the finish line (which has the potential to significantly simplify coverage collecting.

Once #23941 lands, collecting coverage for a single file becomes as simple as:

NODE_V8_COVERAGE=./cov ./tools/test.py parallel/test-fs-mkdir.js
c8 report --temp-dir=./cov --resolve=./lib --reporter=html --omit-relative-false

@wnordmann
Copy link
Author

I appreciate the two solutions to the problem. I'll hold out and test with #23941 once it lands.

@antsmartian
Copy link
Contributor

@wnordmann : #23941 landed. So you are still gonna work on this? I just tried playing around and looks like the following command does generates the coverage:

NODE_V8_COVERAGE=./cov ./tools/test.py parallel/test-fs-mkdir.js
c8 report --temp-directory=./cov --resolve=./lib --reporter=html

However, the index.html which was generated just shows the empty page, but the corresponding lib/<file> does shows the coverage for the given test case. @bcoe Anything I'm missing here?

@bcoe
Copy link
Contributor

bcoe commented Jan 20, 2019

@wnordmann @antsmartian please try:

d1dee49

which was just landed; it has new instructions.

@jasnell
Copy link
Member

jasnell commented Jun 19, 2020

I believe this is resolved or not further actionable. Closing. Can reopen if necessary

@jasnell jasnell closed this as completed Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coverage Issues and PRs related to native coverage support. test Issues and PRs related to the tests.
Projects
None yet
Development

No branches or pull requests

7 participants