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

assert: add env to show the full error #22119

Closed
wants to merge 2 commits into from

Conversation

BridgeAR
Copy link
Member

@BridgeAR BridgeAR commented Aug 4, 2018

This adds the NODE_ASSERT_FULL environment variable to give the
user the option to opt into seeing the full error message even though
the diff is at least partially identical.

Fixes: #19106

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

This adds the `NODE_ASSERT_FULL` environment variable to give the
user the option to opt into seeing the full error message even though
the diff is at least partially identical.

Fixes: nodejs#19106
@BridgeAR BridgeAR added the semver-minor PRs that contain new features and should be released in the next minor version. label Aug 4, 2018
@nodejs-github-bot nodejs-github-bot added the assert Issues and PRs related to the assert subsystem. label Aug 4, 2018
Using that environment variable will also deactivate the colors in the REPL.

The diff will also be minified in case more than three lines are identical or if
either side of an loose equal check is longer than 128 characters. To prevent
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: an loose -> a loose.

@vsemozhetbyt
Copy link
Contributor

It seems these 3 files should also be updated?

https://github.com/nodejs/node/blob/master/doc/api/cli.md#environment-variables

node/doc/node.1

Line 274 in 0518b9e

.Sh ENVIRONMENT

node/src/node.cc

Line 2580 in 0518b9e

static void PrintHelp() {

@BridgeAR
Copy link
Member Author

BridgeAR commented Aug 6, 2018

Comments addressed. PTAL.

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

@vsemozhetbyt
Copy link
Contributor

Docs LGTM.

@jasnell
Copy link
Member

jasnell commented Aug 8, 2018

hmm... not really a fan of introducing new environment variables at this point. Why would this not be an API option?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@BridgeAR
Copy link
Member Author

BridgeAR commented Aug 9, 2018

@jasnell assert has no options so far. I thought about three different implementations: a) using the environment variable. b) Refactoring assert in a backwards compatible way to a class and allowing defaults. c) adding options to the function calls.

a) is the most straight forward
b) is more work but it would probably be the nicest API
c) adding options directly to the API call prevents different possibilities. The API is also not that nice to use.

I am against c) because I would like to go into a different direction there. I could rewrite it to b) if you would rather have that. In that case the assert as is currently exist would just be a instance of the class.

@jasnell
Copy link
Member

jasnell commented Aug 9, 2018

I'd almost prefer option B. Yes, it's more work, but environment variables are not really a great approach, even if simple.

@joyeecheung
Copy link
Member

Can't really review the code as I am not really familiar with assert.js now, but I don't mind the environment variable as options in assert makes it more complicated. In general +1 to the idea

@BridgeAR BridgeAR added the blocked PRs that are blocked by other issues or PRs. label Aug 11, 2018
@addaleax
Copy link
Member

addaleax commented Sep 2, 2018

@BridgeAR assert should definitely have options, it already depends on things it should not depend on (like color properties of streams where data may or may not end up). This PR, in its current form, makes things worse.

I’m not sure if I understand option b) correctly, but if it’s something like new assert.Assert({ colors: <bool>, strict: <bool>, fullErrors: <bool>, … }), I’m on board.

@BridgeAR
Copy link
Member Author

BridgeAR commented Sep 2, 2018

@addaleax yes, you understood correct :-) I am planning to open a new PR with that change soon and to close this one at that point.

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

Red X'ing this just to make sure no one lands it. My understanding is that a new PR will be opened that introduces an option rather than using an environment variable like this PR does.

@BridgeAR
Copy link
Member Author

Closing for now. I'll open a new PR when I get to it.

@BridgeAR BridgeAR closed this Dec 19, 2018
@BridgeAR BridgeAR deleted the full-assertion-errr branch January 20, 2020 11:34
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. blocked PRs that are blocked by other issues or PRs. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide options for assert.strictEqual to display full strings
8 participants