Skip to content

test: add coverage for sparse array maxArrayLength - #27901

Closed
wentout wants to merge 2 commits into
nodejs:masterfrom
wentout:cl_test_4_sparsed_array
Closed

test: add coverage for sparse array maxArrayLength#27901
wentout wants to merge 2 commits into
nodejs:masterfrom
wentout:cl_test_4_sparsed_array

Conversation

@wentout

Copy link
Copy Markdown
Contributor

code and learn task for additional coverage for situation when
maxArrayLength option is passed to util.inspect for sparsed array
and is set to number lower than actual number of entries

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-botnodejs-github-bot added the test Issues and PRs related to the tests. label May 26, 2019

@ryzokukenryzokuken left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks!

@ryzokukenryzokuken added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label May 26, 2019
@TrottTrott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 27, 2019
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@mhdawsonmhdawson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@BridgeARBridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this really cover the correct part? It seems to be handled in the fast path (formatArray) since it did not yet detect that it's actually a sparse array.

@BridgeARBridgeAR removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 29, 2019
@Trott

Copy link
Copy Markdown
Member

(Typo in commit message. Can be fixed when landing, though. s/sparsed/sparse/)

@wentoutwentout changed the title test: add coverage for sparsed array maxArrayLengthtest: add coverage for sparse array maxArrayLengthMay 29, 2019
@wentout

Copy link
Copy Markdown
ContributorAuthor

Does this really cover the correct part? It seems to be handled in the fast path (formatArray) since it did not yet detect that it's actually a sparse array.

The task was to try to make it for .formatSpecialArray method of lib/internal/util/inspect.js L1183
https://coverage.nodejs.org/coverage-99268b1e996d13a0/lib/internal/util/inspect.js.html#L1183.

The test is for this line only. The array is already made sparsed on previous test lines. So the detection is on the previous one-liner test there is <1 empty item> string check.

As for failed build checks, I don't understand how it was able to touch the build itself via test file. Please navigate me to understanding.

@wentout
wentoutforce-pushed the cl_test_4_sparsed_array branch 2 times, most recently from 4fec302 to 5ce3d10CompareMay 30, 2019 00:32
@wentout

wentout commented May 30, 2019

Copy link
Copy Markdown
ContributorAuthor

I think after changes coverage is correct.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@Trott

Copy link
Copy Markdown
Member

/ping @BridgeAR Is this good to land? Or are you still concerned that it doesn't cover the code path intended?

@BridgeARBridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. This will now cover the correct part. It would still be nice though to address the comment to simplify the test case.

Comment threadtest/parallel/test-util-inspect.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ideally this could be moved down to be the very last test case. That way there are already enough entries in the array and it would work without pushing / splicing / deleting entries. Calling splice should definitely not be required.

(So below here https://github.com/nodejs/node/blob/5ce3d10434e0d81934f7013a2a13d1502be6aca6/test/parallel/test-util-inspect.js#L520)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Ah, I understand.
I will redo.
.splice is heavy :)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Moved too the end of sparse array tests.
Made coverage check for line 1183 again, it is there/
image

wentout added 2 commits May 30, 2019 19:53
code and learn task for additional coverage for situation when
maxArrayLength option is passed to util.inspect for sparsed array
and is set to number lower than actual number of entries
@wentout
wentoutforce-pushed the cl_test_4_sparsed_array branch from 5ce3d10 to 3eca651CompareMay 30, 2019 16:53

@BridgeARBridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks a lot for following up on it!

@wentout

Copy link
Copy Markdown
ContributorAuthor

Thanks a lot for following up on it!

Nothing for!
And vice a versa for you from all this explanations. Much appreciate! Wish I'd be as good mentor.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@ryzokuken

Copy link
Copy Markdown
Contributor

Passed! Landing this.

pullBot pushed a commit to Pandinosaurus/node that referenced this pull request Jun 1, 2019
code and learn task for additional coverage for situation when
maxArrayLength option is passed to util.inspect for sparse array
and is set to number lower than actual number of entries
PR-URL: nodejs#27901
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@ryzokuken

Copy link
Copy Markdown
Contributor

Landed in dcd0ba1 w/ @Trott's comments. 🎉

targos pushed a commit that referenced this pull request Jun 1, 2019
code and learn task for additional coverage for situation when
maxArrayLength option is passed to util.inspect for sparse array
and is set to number lower than actual number of entries
PR-URL: #27901
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@targostargos mentioned this pull request Jun 3, 2019
@nodejsnodejs deleted a comment from tacoto12Apr 8, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-and-learnIssues related to the Code-and-Learn events and PRs submitted during the events.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@wentout@nodejs-github-bot@Trott@ryzokuken@addaleax@cjihrig@gireeshpunathil@BridgeAR@mhdawson