-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: refactor test-fs-read-stream-inherit #13618
Conversation
* block scope `paused` * change name of block-scoped `file3` etc. to `file` * alphabetize modules * confirm contents provided in `data` callback * confirm `data` callbacks will not fire on tests for errors
file3.on('data', function(data) { | ||
const file = fs.createReadStream(fn, Object.create({encoding: 'utf8'})); | ||
file.length = 0; | ||
file.on('data', function(data) { |
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.
Do we have any preferences whether to use lambdas or good old function declarations when they are interchangeable?
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.
By lambdas you mean () => {}
(fat arrow) functions? I don't think we have an official policy (although I personally prefer fat arrow functions because they seem simpler).
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.
@gibfahn Exactly, that would be my preference as well.
file5.on('end', common.mustCall(function() { | ||
assert.strictEqual(file5.data, 'yz\n'); | ||
file.on('end', common.mustCall(function() { | ||
assert.strictEqual(file.data, 'yz\n'); |
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.
If you're here could you parameterize the 'yz\n'
, here and in L106
file7Next(); | ||
assert(!file.closed); | ||
assert(!file.destroyed); | ||
assert.strictEqual(data, 'xyz\n'); |
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.
ditto
file7.data = ''; | ||
file7.on('data', function(data) { | ||
file7.data += data; | ||
file = fs.createReadStream(null, Object.create({fd: file.fd, start: 0 })); |
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 is just weird, shadowing file
but AFAICT only affects L147-8 , so there it asserts the state of this file
🤔
IMHO it's wrong, but maybe not for this PR...
Landed in 3c506af |
* block scope `paused` * change name of block-scoped `file3` etc. to `file` * alphabetize modules * confirm contents provided in `data` callback * confirm `data` callbacks will not fire on tests for errors PR-URL: nodejs#13618 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* block scope `paused` * change name of block-scoped `file3` etc. to `file` * alphabetize modules * confirm contents provided in `data` callback * confirm `data` callbacks will not fire on tests for errors PR-URL: #13618 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* block scope `paused` * change name of block-scoped `file3` etc. to `file` * alphabetize modules * confirm contents provided in `data` callback * confirm `data` callbacks will not fire on tests for errors PR-URL: #13618 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This does not land cleanly in LTS. Please feel free to manually backport. Please also feel free to replace do-not-land if it is being backported |
paused
file3
etc. tofile
data
callbackdata
callbacks will not fire on tests for errorsChecklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test fs