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: use portable EOL #32104

Closed

Conversation

HarshithaKP
Copy link
Member

@HarshithaKP HarshithaKP commented Mar 5, 2020

The test wanted to cut huge string into 1KB strings,
for which a new line character was inserted at appropriate
places. The value is different in Windows (10, 13).
Make it portable, by making use of os.EOL semantics

Refs: #25988

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

The test wanted to cut huge string into 1KB strings,
for which a new line character was inserted at appropriate
places. The value is different in Windows (10, 13).
Make it portable, by making use of os.EOL semantics

Refs: nodejs#25988
@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Mar 5, 2020
@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 7, 2020
@nodejs-github-bot
Copy link
Collaborator

@gireeshpunathil
Copy link
Member

the modified test is failing in windows (10 and 2016) with one byte loss!

https://ci.nodejs.org/job/node-test-binary-windows-js-suites/RUN_SUBSET=0,nodes=win2016-COMPILED_BY-vs2017/2224/console

11:59:29     AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
11:59:29     + actual - expected
11:59:29     
11:59:29     + '1048575'
11:59:29     - '1048576'

can't think of a reason!

@addaleax addaleax removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 9, 2020
@addaleax
Copy link
Member

addaleax commented Mar 9, 2020

can't think of a reason!

Previously, the data in the file was of the structure

\n
xxxxxxx...xxx\n
xxxxxxx...xxx\n
...
xxxxxxx...xxx\n
xxxxxxx...xxx

which grep x would turn into

xxxxxxx...xxx\n
xxxxxxx...xxx\n
...
xxxxxxx...xxx\n
xxxxxxx...xxx\n

(i.e. remove the empty line, but also add a trailing UNIX-style newline at the end.)

I assume that now, where the file structure is

\r\n
xxxxxxx...xxx\r\n
xxxxxxx...xxx\r\n
...
xxxxxxx...xxx\r\n
xxxxxxx...xxx

grep turns that into

xxxxxxx...xxx\r\n
xxxxxxx...xxx\r\n
....
xxxxxxx...xxx\r\n
xxxxxxx...xxx\n

i.e. grep still drops the empty line and adds a newline, but (like before) a UNIX-style one instead of a Windows-style one.

@gireeshpunathil
Copy link
Member

great catch @addaleax !! I never knew we were loosing one byte and getting it back from grep!!

@addaleax
Copy link
Member

addaleax commented Mar 9, 2020

@gireeshpunathil You can reproduce this pretty easily on UNIX, too, by replacing os.EOL with \r\n in this PR.

@HarshithaKP
Copy link
Member Author

@addaleax, I made changes in the test to remove the new line in the beginning of the buffer and considered one extra byte which grep provides while doing assertion. Please take a look.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 13, 2020
@nodejs-github-bot
Copy link
Collaborator

@addaleax
Copy link
Member

Landed in 4fedb70

@addaleax addaleax closed this Mar 13, 2020
addaleax pushed a commit that referenced this pull request Mar 13, 2020
The test wanted to cut huge string into 1KB strings,
for which a new line character was inserted at appropriate
places. The value is different in Windows (10, 13).
Make it portable, by making use of os.EOL semantics

Refs: #25988

PR-URL: #32104
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
HarshithaKP added a commit to HarshithaKP/node that referenced this pull request Mar 13, 2020
`buffer.write` documentation has an incaccuracy w.r.t the `length`
parameter: It says default number of bytes written is
`buf.length - offset`. Change it to:
If the buffer has sufficient space from the offset, the string is
written upto `length`.
If the buffer is short in space, only `buf.length - offset` bytes are
written.

Refs : nodejs#32104 (comment)
BridgeAR pushed a commit that referenced this pull request Mar 17, 2020
The test wanted to cut huge string into 1KB strings,
for which a new line character was inserted at appropriate
places. The value is different in Windows (10, 13).
Make it portable, by making use of os.EOL semantics

Refs: #25988

PR-URL: #32104
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@MylesBorins MylesBorins mentioned this pull request Mar 19, 2020
MylesBorins pushed a commit that referenced this pull request Mar 24, 2020
The test wanted to cut huge string into 1KB strings,
for which a new line character was inserted at appropriate
places. The value is different in Windows (10, 13).
Make it portable, by making use of os.EOL semantics

Refs: #25988

PR-URL: #32104
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
addaleax pushed a commit that referenced this pull request Apr 5, 2020
`buffer.write` documentation has an incaccuracy w.r.t the `length`
parameter: It says default number of bytes written is
`buf.length - offset`. Change it to:
If the buffer has sufficient space from the offset, the string is
written upto `length`.
If the buffer is short in space, only `buf.length - offset` bytes are
written.

Refs: #32104 (comment)

PR-URL: #32119
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
BethGriggs pushed a commit that referenced this pull request Apr 7, 2020
`buffer.write` documentation has an incaccuracy w.r.t the `length`
parameter: It says default number of bytes written is
`buf.length - offset`. Change it to:
If the buffer has sufficient space from the offset, the string is
written upto `length`.
If the buffer is short in space, only `buf.length - offset` bytes are
written.

Refs: #32104 (comment)

PR-URL: #32119
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
targos pushed a commit that referenced this pull request Apr 12, 2020
`buffer.write` documentation has an incaccuracy w.r.t the `length`
parameter: It says default number of bytes written is
`buf.length - offset`. Change it to:
If the buffer has sufficient space from the offset, the string is
written upto `length`.
If the buffer is short in space, only `buf.length - offset` bytes are
written.

Refs: #32104 (comment)

PR-URL: #32119
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
targos pushed a commit that referenced this pull request Apr 22, 2020
The test wanted to cut huge string into 1KB strings,
for which a new line character was inserted at appropriate
places. The value is different in Windows (10, 13).
Make it portable, by making use of os.EOL semantics

Refs: #25988

PR-URL: #32104
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
targos pushed a commit that referenced this pull request Apr 22, 2020
`buffer.write` documentation has an incaccuracy w.r.t the `length`
parameter: It says default number of bytes written is
`buf.length - offset`. Change it to:
If the buffer has sufficient space from the offset, the string is
written upto `length`.
If the buffer is short in space, only `buf.length - offset` bytes are
written.

Refs: #32104 (comment)

PR-URL: #32119
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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