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: do not use EOL in ERR_ASSERTION messages #19221

Closed
wants to merge 1 commit into from

Conversation

joyeecheung
Copy link
Member

On Windows if an error is thrown from a script that uses \n
to break lines - which is very common in the JavaScript ecosystem,
and is the case in our own code base -
then the error messages would contain mixed line feeds:
the part coming from the source code breaks with \n while the
message itself break with \r\n.

Since we do not use \r\n in util.inspect(), we should use \n
in error messages as well.

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

cc @BridgeAR

On Windows if an error is thrown from a script that uses `\n`
to break lines - which is very common in the JavaScript ecosystem,
and is the case in our own code base -
then the error messages would contain mixed line feeds:
the part coming from the source code breaks with `\n` while the
message itself break with `\r\n`.

Since we do not use `\r\n` in util.inspect(), we should use `\n`
in error messages as well.
@nodejs-github-bot nodejs-github-bot added the assert Issues and PRs related to the assert subsystem. label Mar 8, 2018
@joyeecheung
Copy link
Member Author

joyeecheung commented Mar 8, 2018

I am wondering why this does not fail on the CI but fails on my Windows 10 machine. I have core.autocrlf = false because if I let git convert LF to CRLF the linter would go crazy about it.

EDIT: huh, I guess it's because the windows CI does not run the linter so it just converts LF in the code to CRLF and gets away with it..

@joyeecheung
Copy link
Member Author

@vsemozhetbyt
Copy link
Contributor

Refs: #18967

@vsemozhetbyt
Copy link
Contributor

Is this semver-major?

@BridgeAR
Copy link
Member

BridgeAR commented Mar 8, 2018

@vsemozhetbyt this is not semver-major because it relies on a semver-major feature. I added the do not land labels.

@BridgeAR BridgeAR added the fast-track PRs that do not need to wait for 48 hours to land. label Mar 8, 2018
@BridgeAR
Copy link
Member

BridgeAR commented Mar 8, 2018

@joyeecheung this currently fails on the CI. When I implemented this I had the exact same issue when first using \n because something converted that to \r\n on Windows. I personally would like to only use \n but I am not sure how Windows handles this.

@joyeecheung
Copy link
Member Author

@nodejs/build Can we set git config core.autocrlf false on the Windows CI? Letting git convert LF to CRLF causes the linter to fail on a Windows machine.

@joyeecheung joyeecheung added the errors Issues and PRs related to JavaScript errors originated in Node.js core. label Mar 14, 2018
@MSLaguana
Copy link
Contributor

Instead of setting a git config option, wouldn't it be better to add a line to .gitattributes explicitly specifying what line ending the relevant files are required to have?

@joyeecheung
Copy link
Member Author

@MSLaguana That sounds like a better idea, I'll try to figure out the necessary update to .gitattributes, thanks for the advice!

@joaocgreis
Copy link
Member

We should try to respect naive EOL where possible. I believe a better solution would be to mark this test explicitly for EOL normalization, adding something like this to .gitattributes:

test/parallel/test-assert.js text

@BridgeAR
Copy link
Member

Superseded by #20754. Closing.

@BridgeAR BridgeAR closed this May 18, 2018
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. errors Issues and PRs related to JavaScript errors originated in Node.js core. fast-track PRs that do not need to wait for 48 hours to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants