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

test_runner: refactor coverage report output for readability #47791

Merged
merged 11 commits into from
Jun 7, 2023

Conversation

dmnsgn
Copy link
Contributor

@dmnsgn dmnsgn commented Apr 30, 2023

Add a "table" parameter to getCoverageReport.
Keep the tap coverage output intact.
Change the output by adding padding and truncating the tables' cells. Add separation lines for table head/body/foot.
Group uncovered lines as ranges.
Add yellow color for coverage between 50 and 90.

Refs: #46674

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added dont-land-on-v14.x needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Apr 30, 2023
}
return coverage;
function addTableLine(prefix, width) {
return `${prefix}${'-'.repeat(width)}\n`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return `${prefix}${'-'.repeat(width)}\n`;
return `${prefix}${StringPrototypeRepeat('-', width)}\n`;

also consider memoizing, like https://github.com/nodejs/node/blob/102540aef9024ea6a8218a6d782243f1391612d2/lib/internal/test_runner/reporter/tap.js#L88-97

@MoLow
Copy link
Member

MoLow commented Apr 30, 2023

Thanks for this PR, it really improves the output of the coverage report.

dmnsgn added a commit to dmnsgn/node that referenced this pull request Apr 30, 2023
@dmnsgn
Copy link
Contributor Author

dmnsgn commented Apr 30, 2023

@MoLow Thanks! I have now implemented all your feedbacks.

@cjihrig
Copy link
Contributor

cjihrig commented May 24, 2023

@dmnsgn are you planning to continue working on this?

@dmnsgn
Copy link
Contributor Author

dmnsgn commented May 25, 2023

@dmnsgn are you planning to continue working on this?

All yours and @MoLow comments have been implemented and I think that's as much I can contribute as of now.
Hope this helps and happy to leave it in your hands from now on.

@dmnsgn
Copy link
Contributor Author

dmnsgn commented Jun 5, 2023

Conflicts all fixed as well.

@MoLow
Copy link
Member

MoLow commented Jun 6, 2023

can you please squash this branch / omit the merge commit?

@dmnsgn dmnsgn force-pushed the coverage-spec-table-format branch from c86191b to 98a327b Compare June 6, 2023 16:06
@dmnsgn
Copy link
Contributor Author

dmnsgn commented Jun 6, 2023

@MoLow done, I rebased it.

@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 6, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 6, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@MoLow MoLow added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Jun 7, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 7, 2023
@nodejs-github-bot nodejs-github-bot merged commit 23c7f65 into nodejs:main Jun 7, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 23c7f65

function formatLinesToRanges(values) {
return ArrayPrototypeMap(ArrayPrototypeReduce(values, (prev, current, index, array) => {
if ((index > 0) && ((current - array[index - 1]) === 1)) {
prev[prev.length - 1][1] = current;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .at(-1)?

if (truncate) result = truncate(result, width);
if (color && coverage !== undefined) {
if (coverage > 90) return `${coverageColors.high}${result}${color}`;
if (coverage > 50) return `${coverageColors.medium}${result}${color}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if these values should be configurable someway...

@piranna
Copy link
Contributor

piranna commented Jun 7, 2023

I missed to publish my review before, anyway good to know this has landed :-)

RafaelGSS pushed a commit that referenced this pull request Jul 3, 2023
Add a "table" parameter to getCoverageReport.
Keep the tap coverage output intact.
Change the output by adding padding and truncating the tables' cells.
Add separation lines for table head/body/foot.
Group uncovered lines as ranges.
Add yellow color for coverage between 50 and 90.

Refs: #46674
PR-URL: #47791
Reviewed-By: Moshe Atlow <[email protected]>
@RafaelGSS RafaelGSS mentioned this pull request Jul 3, 2023
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
Add a "table" parameter to getCoverageReport.
Keep the tap coverage output intact.
Change the output by adding padding and truncating the tables' cells.
Add separation lines for table head/body/foot.
Group uncovered lines as ranges.
Add yellow color for coverage between 50 and 90.

Refs: nodejs#46674
PR-URL: nodejs#47791
Reviewed-By: Moshe Atlow <[email protected]>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
Add a "table" parameter to getCoverageReport.
Keep the tap coverage output intact.
Change the output by adding padding and truncating the tables' cells.
Add separation lines for table head/body/foot.
Group uncovered lines as ranges.
Add yellow color for coverage between 50 and 90.

Refs: nodejs#46674
PR-URL: nodejs#47791
Reviewed-By: Moshe Atlow <[email protected]>
ruyadorno pushed a commit that referenced this pull request Aug 29, 2023
Add a "table" parameter to getCoverageReport.
Keep the tap coverage output intact.
Change the output by adding padding and truncating the tables' cells.
Add separation lines for table head/body/foot.
Group uncovered lines as ranges.
Add yellow color for coverage between 50 and 90.

Refs: #46674
PR-URL: #47791
Reviewed-By: Moshe Atlow <[email protected]>
@ruyadorno ruyadorno mentioned this pull request Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants