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: add coverage for sparse array maxArrayLength #27901

Closed
wants to merge 2 commits into from

Conversation

wentout
Copy link
Contributor

@wentout wentout commented May 26, 2019

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-bot nodejs-github-bot added the test Issues and PRs related to the tests. label May 26, 2019
Copy link
Contributor

@ryzokuken ryzokuken left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@ryzokuken ryzokuken added the code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. label May 26, 2019
@Trott Trott 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.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@BridgeAR BridgeAR left a comment

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.

@BridgeAR BridgeAR 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
Member

Trott commented May 29, 2019

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

@wentout wentout changed the title test: add coverage for sparsed array maxArrayLength test: add coverage for sparse array maxArrayLength May 29, 2019
@wentout
Copy link
Contributor Author

wentout commented May 29, 2019

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 wentout force-pushed the cl_test_4_sparsed_array branch 2 times, most recently from 4fec302 to 5ce3d10 Compare May 30, 2019 00:32
@wentout
Copy link
Contributor Author

wentout commented May 30, 2019

I think after changes coverage is correct.

@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented May 30, 2019

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

Copy link
Member

@BridgeAR BridgeAR left a comment

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.

delete a[3];
assert.strictEqual(util.inspect(a, {
maxArrayLength: 2
}), "[ 'foo', <1 empty item>, ... 3 more items ]");
Copy link
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
Contributor Author

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
Contributor Author

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

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
Copy link
Member

@BridgeAR BridgeAR left a comment

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
Contributor Author

wentout commented May 30, 2019

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
Collaborator

@ryzokuken
Copy link
Contributor

Passed! Landing this.

pull bot 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 <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ujjwal Sharma <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@ryzokuken
Copy link
Contributor

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

@ryzokuken ryzokuken closed this Jun 1, 2019
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 <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ujjwal Sharma <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@targos targos mentioned this pull request Jun 3, 2019
@nodejs nodejs deleted a comment from tacoto12 Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-and-learn Issues related to the Code-and-Learn events and PRs submitted during the events. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants