-
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: add block-scoping to test-fs-watch-encoding #25532
Conversation
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.
Hi Lakshmi, thanks for the contribution, but I'm not in favour. Rockets (() => {}
) are useful for inline functions, and while it is possible to create a rocket, then assign it to a const to emulate the function ...
syntax, its less clear when used like this, and even textually longer. I don't think this is a class of change we want to make in node. There are 790+ instances of this in test/parallel alone, much less the rest of node, but I'm not aware of any cases of "const rockets" at the file scope.
There are lots of things that can be improved about our test suites, maybe we can find some other kinds of refactorings you would be interested in working on?
@LakshmiSwethaG Welcome and thanks for the pull request! I agree with @sam-github that this is not a desirable change. However, instead, in the same file, perhaps you can refactor it to block-scope things so that we don't have For example, instead of this: const watcher1 = fs.watch(
tmpdir.path,
{ encoding: 'hex' },
(event, filename) => {
if (['e696b0e5bbbae69687e5a4b9e4bbb62e747874', null].includes(filename))
done(watcher1);
}
);
registerWatcher(watcher1); ...it could be block-scoped like this: {
const watcher = fs.watch(
tmpdir.path,
{ encoding: 'hex' },
(event, filename) => {
if (['e696b0e5bbbae69687e5a4b9e4bbb62e747874', null].includes(filename))
done(watcher);
}
);
registerWatcher(watcher);
} ...and similarly for Then, a comment can be added to each of the three block-scopes explaining exactly what it is testing. One short sentence or sentence fragment in each case should be enough. So the block above, might have this comment added to it: // Test that using the `encoding` option has the expected result. |
@sam-github and @Trott Thanks for your suggestions. I have updated the commit with @Trott suggestions. Please review and suggest. |
PR is completely different from initial PR. Needs re-review. Dismissing all existing reviews.
Should probably wait 48 hours from #25532 (comment) before landing. Otherwise, this seems good to land (unless someone notices something and comments between now and then). |
Landed in 0f0e7f5 🎉 |
PR-URL: #25532 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #25532 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes