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: fix diff color output #19464

Closed
wants to merge 1 commit into from
Closed

Conversation

BridgeAR
Copy link
Member

@BridgeAR BridgeAR commented Mar 20, 2018

The color output was broken at some point and that was not detected
because it was not tested for properly so far. This makes sure the
colors work again and it adds a regression test as well.

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

@nodejs-github-bot nodejs-github-bot added the errors Issues and PRs related to JavaScript errors originated in Node.js core. label Mar 20, 2018
@BridgeAR
Copy link
Member Author

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

The color output was broken at some point and that was not detected
because it was not tested for properly so far. This makes sure the
colors work again and it adds a regression test as well.
@BridgeAR
Copy link
Member Author

Rebased due to conflicts.

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

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 added a commit to BridgeAR/node that referenced this pull request Mar 27, 2018
The color output was broken at some point and that was not detected
because it was not tested for properly so far. This makes sure the
colors work again and it adds a regression test as well.

PR-URL: nodejs#19464
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@BridgeAR
Copy link
Member Author

Landed in 2e6dd93

@BridgeAR BridgeAR closed this Mar 27, 2018
@targos
Copy link
Member

targos commented Apr 2, 2018

Should this be backported to v9.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

BridgeAR added a commit to BridgeAR/node that referenced this pull request May 1, 2018
The color output was broken at some point and that was not detected
because it was not tested for properly so far. This makes sure the
colors work again and it adds a regression test as well.

PR-URL: nodejs#19464
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@jasonkarns
Copy link
Member

Should those color values be calculated just once instead of on every AssertionError instantiation?

The comment Reset on each call to make sure we handle dynamically set environment variables correct. Is this only for node's own test suite?

When else would those env vars change after the first AssertionError?

@BridgeAR
Copy link
Member Author

@jasonkarns it is theoretically possible to change environment settings at any point of time. As far as I know there is no rule so far about when to check for environment settings. There are multiple possibilities:

  1. Check on startup and keep it that way.
  2. Check on first use and keep it that way.
  3. Check on each use.

In this case I decided to go for the latter without having a strong opinion on either case. Do you see a downside in this specific behavior?

@jasonkarns
Copy link
Member

@BridgeAR yep, theoretically possible since of course anything under process. is mutable :D Just seems that practically speaking, these assertions will be used primarily for test suites, and it would be extremely unlikely for the system under test to modify those values in between tests.

The only downside is just the "waste" of recalculating those values when, in practice, they'll never change. Almost more valuable is the code cleanliness of just having them defined once as consts at the top: 7914a34#diff-5a3344c263a73c663dd1cfcb91880fd7R18

I'm typically on team "don't pre-optimize". But in this case it just feels weird to have the code contort and be defensive about such a scenario.

🤷‍♂️

@BridgeAR
Copy link
Member Author

@jasonkarns the overhead for this is pretty tiny compared to creating the stack trace etc.

I checked our code base again and in most cases we check the env on each use. Since there is no rule to it so far we should likely keep this behavior in place (what ever reason a user might have to change the environment variables during runtime).

@BridgeAR BridgeAR deleted the fix-colors branch April 1, 2019 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants