node icon indicating copy to clipboard operation
node copied to clipboard

test: support glob matching coverage files

Open avivkeller opened this issue 1 year ago β€’ 14 comments

Fixes #53508 Fixes #51222

This Pull Request introduces two new command-line interface flags to Node.js:

  • --test-coverage-include: Allows users to specify glob patterns to include specific files in the coverage report.
  • --test-coverage-exclude: Allows users to specify glob patterns to exclude specific files from the coverage report.

Notable change text, if any:


Individual file patterns can now be excluded or exclusively included in coverage reports:

- To exclude a specific pattern, use `--test-coverage-exclude`. For example:
  ```bash
  node --experimental-test-coverage --test-coverage-exclude=**/*.test.js path/to/test.js
  ```
  This command excludes all files ending with `.test.js` from the coverage report.

- To include only files that match a specific pattern, use `--test-coverage-include`. For example:
  ```bash
  node --experimental-test-coverage --test-coverage-include=src/**/*.js path/to/test.js
  ```
  This command includes only `.js` files located in the `src` directory and its subdirectories in the coverage report.

Both options can be specified multiple times to match multiple glob patterns. If both options are used in unison, files will need to abide by both guidelines.

avivkeller avatar Jun 22 '24 23:06 avivkeller

Review requested:

  • [ ] @nodejs/test_runner

nodejs-github-bot avatar Jun 22 '24 23:06 nodejs-github-bot

Blocked by #52881 - This PR relies on the path.matchesGlob method to match the coverage files.

(Test failures will disappear once the blocking PR lands)


If a PR relies on a semver-minor change, does it become semver-minor?

avivkeller avatar Jun 22 '24 23:06 avivkeller

please take a look at the test failures

MoLow avatar Jun 23 '24 06:06 MoLow

Thanks! I'll made those changes!

I've also unblocked the PR because the blocking PR has landed

avivkeller avatar Jun 23 '24 11:06 avivkeller

Nice one! ❀️

About the run option, will those new options be supported?

Ideally, as we have files option, it'd be nice to be able to pass the coverage exclusion files too.

I'm not planning on that, this is specific to coverage, not all of testing.

avivkeller avatar Jun 24 '24 11:06 avivkeller

I need to review the new test failures, I'll address them when I get a chance

avivkeller avatar Jun 24 '24 17:06 avivkeller

Hey, if someone could approve + CI, that would help this move to author-ready. Thanks!

avivkeller avatar Jun 26 '24 01:06 avivkeller

CI: https://ci.nodejs.org/job/node-test-pull-request/59978/

nodejs-github-bot avatar Jun 26 '24 13:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/59979/

nodejs-github-bot avatar Jun 26 '24 14:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/59980/

nodejs-github-bot avatar Jun 26 '24 15:06 nodejs-github-bot

@RedYetiDev please resolve conflicts

MoLow avatar Jun 27 '24 09:06 MoLow

@MoLow I've resolved the conflicts via the Github UI, but I know the bot isn't always happy with that. Let me know if it fails to land, and I'll rebase manually.

avivkeller avatar Jun 27 '24 21:06 avivkeller

@RedYetiDev merge commits tend to cause failures in Jenkins CI, could you rebase?

atlowChemi avatar Jun 28 '24 04:06 atlowChemi

Just as a side note, please don’t consider this as a blocker for this change. I’m working on this from the V8 side. Take this discussion as a reference.

https://chromium-review.googlesource.com/c/v8/v8/+/5042949

Maybe once landed this could be potentially easier to implement after cherry picking?

juanarbol avatar Jun 30 '24 06:06 juanarbol

~~:thinking: the CI bot seems to have not picked this up, re-adding label. LMK if I'm missing something.~~

edit: I see the CI is undergoing some changes, I guess it's just waiting.

avivkeller avatar Jul 02 '24 18:07 avivkeller

@RedYetiDev CI is in lock-down for security release & maintenance

atlowChemi avatar Jul 02 '24 18:07 atlowChemi

CI: https://ci.nodejs.org/job/node-test-pull-request/60046/

nodejs-github-bot avatar Jul 04 '24 01:07 nodejs-github-bot

I think CI passed, but I don't have permission to verify that.

avivkeller avatar Jul 05 '24 12:07 avivkeller

This needs to land manually to amend the message and squash. I am away from computer so will do when I am back

MoLow avatar Jul 07 '24 21:07 MoLow

CI: https://ci.nodejs.org/job/node-test-pull-request/60150/

nodejs-github-bot avatar Jul 07 '24 21:07 nodejs-github-bot

@MoLow did you ever get a chance to prepare for manually land?

avivkeller avatar Jul 11 '24 19:07 avivkeller

CI: https://ci.nodejs.org/job/node-test-pull-request/60309/

nodejs-github-bot avatar Jul 14 '24 17:07 nodejs-github-bot

CI passed πŸŽ‰

avivkeller avatar Jul 14 '24 20:07 avivkeller

The https://github.com/nodejs/node/labels/notable-change label has been added by @benjamingr.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section.

github-actions[bot] avatar Jul 14 '24 22:07 github-actions[bot]

Landed in 4174b731537367db8195da2d1182c90a738fc9f6

nodejs-github-bot avatar Jul 14 '24 22:07 nodejs-github-bot

This was merged with the wrong subsystem (it should be test_runner: IIUC)

aduh95 avatar Jul 16 '24 10:07 aduh95

It looks like the commit message was edited when it landed on v22.x: https://github.com/nodejs/node/commit/3a0fcbb17a6dc37ac7463c01cdc0d633e4ac026b

I'm marking this as backported so it doesn't show up in branch-diff's output.

targos avatar Jul 28 '24 06:07 targos

Why should this not land on 20.x?

JakobJingleheimer avatar Nov 25 '24 17:11 JakobJingleheimer