-
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
Increase test coverage for fs/promises.js #19811
Conversation
@Trott OK, thanks, I'll compare with what's landed there and adjust this. |
(Lone CI failure is unrelated. Can be re-run if this PR isn't going to change, but if there are any changes, we'll have to re-run all of CI anyway. So, either way...) |
166aa52
to
7a97e40
Compare
7a97e40
to
be70489
Compare
@nodejs/fs @nodejs/testing |
test/parallel/test-fs-promises.js
Outdated
code: 'ERR_OUT_OF_RANGE', | ||
type: RangeError | ||
})(err); | ||
} |
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.
As a general note: we can actually use the following instead:
assert.rejects(
// `mode` can't be > 0o777
() => fchmod(handle, (0o777 + 1)),
{
code: 'ERR_OUT_OF_RANGE',
name: 'RangeError [ERR_OUT_OF_RANGE]'
}
);
test/parallel/test-fs-promises.js
Outdated
await mkdtemp(1); | ||
} catch (err) { | ||
// mkdtemp() expects to get a string prefix. | ||
console.log('err', err); |
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: can you please remove the console.log here?
test/parallel/test-fs-promises.js
Outdated
await handle.write(buf2); | ||
const ret2 = await handle.read(Buffer.alloc(11), 0, 11, 0); | ||
assert.strictEqual(ret2.bytesRead, 11); | ||
assert.deepStrictEqual(ret2.buffer, buf); |
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.
Shouldn't this be compared with buf2
?
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: Also, if we reduce magic numbers (like 11 in this case) it would be better.
test/parallel/test-fs-promises.js
Outdated
await chmod(dest, 0o666); | ||
await fchmod(handle, 0o666); | ||
handle.chmod(0o666); | ||
try { | ||
await fchmod(handle, (0o777 + 1)); |
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.
It would be better, if did this for chmod
as well.
@humphd would you be so kind and have a look at the comments? :-) |
@BridgeAR apologies for the delay. I'll update this week. |
be70489
to
d20bde9
Compare
OK, I've rebased and done the following based on the reviews above:
|
test/parallel/test-fs-promises.js
Outdated
await chmod(dest, 0o666); | ||
await fchmod(handle, 0o666); | ||
handle.chmod(0o666); |
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.
Should this be await
ed?
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.
Indeed, thank you for spotting this. I'll fix.
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
OSX CI failure looks unrelated, opened #20660 New CI run: https://ci.nodejs.org/job/node-test-pull-request/14796/ |
Landed in fcc46ee 🎉 |
PR-URL: #19811 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
PR-URL: #19811 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
Thanks for landing this @addaleax, and to the rest for your reviews and help spotting mistakes. |
I was looking at test coverage for the new things in
fs/promises.js
and wanted to add some more. This adds test cases usingFileHandle
objects vs. only using paths or fds.Due to #19057, I'm unable to run coverage locally on macOS; apologies for not including updated coverage info.