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: check custom inspection truncation in assert #28234

Closed
wants to merge 1 commit into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Jun 14, 2019

The assert module has some truncation logic in a custom inspect
function. This was not covered in tests. Add tests to cover it.

The previously-uncovered lines are

if (lines.length > 10) {
lines.length = 10;
this[name] = `${lines.join('\n')}\n...`;
} else if (this[name].length > 512) {
this[name] = `${this[name].slice(512)}...`;
}
.

@BridgeAR I could use some confirmation that this is covering a feature and not revealing a bug. When an ASSERTION_ERROR with a long line is inspected, the value in actual or expected will be truncated but the same value will appear in full in the message. Whoops? Or by design?

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

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Jun 14, 2019
@Trott Trott added the assert Issues and PRs related to the assert subsystem. label Jun 14, 2019
@Trott

This comment has been minimized.

@Trott

This comment has been minimized.

@Trott
Copy link
Member Author

Trott commented Jun 15, 2019

@BridgeAR
Copy link
Member

@Trott

@BridgeAR I could use some confirmation that this is covering a feature and not revealing a bug. When an ASSERTION_ERROR with a long line is inspected, the value in actual or expected will be truncated but the same value will appear in full in the message. Whoops? Or by design?

It is by design: we used to only visualize the stack property in case of a fatal exception and other cases. I changed that recently to fully inspect errors on fatal exceptions. Now all properties on an error will be fully inspected. Since the actual and expected values will be visible in the message anyway, it's better to minimize the output for the properties by default, since it would otherwise duplicate the information and that seems pretty verbose. That was the original reason for me to limit the output for these properties.

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. Thanks for writing the tests for this!

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 15, 2019
});

// Output that extends beyond 10 lines sould also be truncated for display.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: sould -> should

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

The assert module has some truncation logic in a custom inspect
function. This was not covered in tests. Add tests to cover it.

PR-URL: nodejs#28234
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
@Trott Trott force-pushed the check-truncation branch from 09888e3 to e3d5257 Compare June 18, 2019 18:17
@Trott
Copy link
Member Author

Trott commented Jun 18, 2019

Landed in e3d5257

@Trott Trott closed this Jun 18, 2019
@Trott Trott deleted the check-truncation branch June 18, 2019 18:17
targos pushed a commit that referenced this pull request Jul 2, 2019
The assert module has some truncation logic in a custom inspect
function. This was not covered in tests. Add tests to cover it.

PR-URL: #28234
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
@targos targos mentioned this pull request Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert Issues and PRs related to the assert subsystem. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants