-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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: buffer should always be stringified #12355
test: buffer should always be stringified #12355
Conversation
|
||
v.forEach((value) => { | ||
common.refreshTmpDir(); | ||
const fd = fs.openSync(filePath, 'a'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, why 'a'
, not 'w'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can test with all the flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think testing with all flags is an overhead as we are not testing for the fd
but for the buffer
type. @vsemozhetbyt and @thefourtheye what do u think about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest moving the common.refreshTmpDir()
out of the loop and using 'w'
here, that’s much cleaner.
'use strict'; | ||
const common = require('../common'); | ||
|
||
// This test insures that writeSync does support input buffers which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think ensures
will be more suitable than insures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops...good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I don’t quite understand the statement here – you talk about input buffers
for writeSync, but the only time you are actually using buffers is in the readFileSync output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ I think this comment is still unaddressed? It’s just a comment but it’s really a bit confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@addalex I amended the comment here.
af6825b
to
e6d70ae
Compare
|
||
v.forEach((value) => { | ||
common.refreshTmpDir(); | ||
const fd = fs.openSync(filePath, 'a'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest moving the common.refreshTmpDir()
out of the loop and using 'w'
here, that’s much cleaner.
'use strict'; | ||
const common = require('../common'); | ||
|
||
// This test insures that writeSync does support input buffers which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I don’t quite understand the statement here – you talk about input buffers
for writeSync, but the only time you are actually using buffers is in the readFileSync output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with @addaleax's comment addressed. Might want to rename v
to something more descriptive like values
too.
e6d70ae
to
b5db315
Compare
assert.strictEqual(fs.readFileSync(filePath).toString(), value + ''); | ||
}); | ||
|
||
common.refreshTmpDir(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes and creates the temporary directory, so this should be before the tests.
This test makes sure that independently of the buffer type, the input is always stringified and generates a valid input.
b5db315
to
38c76ee
Compare
@addaleax and @thefourtheye does my last change make sense to you? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, sorry – LGTM!
CI failure on Windows looks unrelated. |
This test makes sure that independently of the buffer type, the input is always stringified and generates a valid input. PR-URL: #12355 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Landed in 9e26347 |
This test makes sure that independently of the buffer type, the input is always stringified and generates a valid input. PR-URL: #12355 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This test makes sure that independently of the buffer type, the input is always stringified and generates a valid input. PR-URL: #12355 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This test makes sure that independently of the buffer type, the input is always stringified and generates a valid input. PR-URL: #12355 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Landed on v6.x, LMK if it shouldn't have. |
This test makes sure that independently of the buffer type, the input is always stringified and generates a valid input. PR-URL: #12355 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This test makes sure that independently of the buffer type, the input is always stringified and generates a valid input. PR-URL: #12355 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This test makes sure that independently of the buffer type, the input is always stringified and generates a valid input. PR-URL: nodejs/node#12355 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This test makes sure that independently of the buffer type, the input
is always stringify and generates a valid input.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test fs