-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
doc: list macOS as supporting filename argument #13111
Conversation
/cc @nodejs/platform-macos |
@chris--young thank you very much for the contribution 🥇 It would be extra beneficial if you tried to add some test cases that validate that the |
710747f
to
364720e
Compare
AIX too please.
var fs = require('fs');
fs.watch('myfile', (eventType, filename) => {
console.log(`event type is: ${eventType}`);
if (filename) {
console.log(`filename provided: ${filename}`);
} else {
console.log('filename not provided');
}
});
|
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.
Per my comment - will you please add AIX also into the list?
test/parallel/test-fs-watchfile.js
Outdated
@@ -63,3 +63,25 @@ fs.watchFile(enoentFile, {interval: 0}, common.mustCall(function(curr, prev) { | |||
fs.unwatchFile(enoentFile); | |||
} | |||
}, 2)); | |||
|
|||
// Watch events should callback with a filename | |||
if (common.isLinux || common.isOSX) { |
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 add Windows too. You can also add AIX according to @gireeshpunathil's suggestion.
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 just checked, it passes on windows.
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.
A few nits
test/parallel/test-fs-watchfile.js
Outdated
@@ -63,3 +63,25 @@ fs.watchFile(enoentFile, {interval: 0}, common.mustCall(function(curr, prev) { | |||
fs.unwatchFile(enoentFile); | |||
} | |||
}, 2)); | |||
|
|||
// Watch events should callback with a filename | |||
if (common.isLinux || common.isOSX) { |
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 just checked, it passes on windows.
test/parallel/test-fs-watchfile.js
Outdated
const dir = common.tmpDir + '/watch'; | ||
|
||
fs.mkdir(dir, common.mustCall(function(err) { | ||
assert(!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.
If you could use assert.ifError
if (err) assert.fail(err);
instead. It will rethrow the error so we know what went wrong.
assert(!err)
will just say true != false
test/parallel/test-fs-watchfile.js
Outdated
|
||
fs.watch(dir, common.mustCall(function(eventType, filename) { | ||
this._handle.close(); | ||
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.
For the test to pass on Windows
you should remove the common.refreshTmpDir();
. Don't worry about it, the test harness will take care of it.
test/parallel/test-fs-watchfile.js
Outdated
})); | ||
|
||
fs.writeFile(`${dir}/foo.txt`, 'foo', common.mustCall((err) => { | ||
if (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.
you can replace the whole callback with (err) => assert.ifError(err)
Ref: #13092 (comment)
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.
you should replace the whole callback with common.mustCall((err) => {if (err) assert.fail(err)})
Ref: #13115
@chris--young thanks |
Any idea what's up with that failed windows-fanned test? Seeing this in the logs...
I don't have a Windows box to test on right now, should be able to setup a vm over the weekend if needed. |
Ignore, it's a infrastructure fail. Also the linux fan is backlogged. |
@chris--young if you're not aware of our landing procedure; now that your part is done, we keep the PR open for 48-72 hours so that anyone who might want to voice an opinion will have a chance. Thanks again! |
sweet |
test/parallel/test-fs-watchfile.js
Outdated
const dir = common.tmpDir + '/watch'; | ||
|
||
fs.mkdir(dir, common.mustCall(function(err) { | ||
if (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 replace this with assert.ifError()
?
Edit: Just read @refack comments against assert.ifError()
. It is actually widely used in our tests but what is used here is also ok so feel free to ignore this.
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.
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.
@chris--young - thanks! I am fine with the changes.
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.
Thanks for your contribution! Can you please change the message of the first commit to use doc:
, not docs:
? That can be fixed by whoever lands the commit as well, though.
a89bfd1
to
21535c3
Compare
CI: https://ci.nodejs.org/job/node-test-commit/10067/ |
test/parallel/test-fs-watchfile.js
Outdated
const dir = common.tmpDir + '/watch'; | ||
|
||
fs.mkdir(dir, common.mustCall(function(err) { | ||
if (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.
I'd prefer it to be either a one-liner or to have braces, but maybe it's just me, and it clearly does not violate the code style this way too, so you can ignore this comment :)
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 really think we should use assert.ifError(err)
in these cases.
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.
+1
Either one liner or braces.
test/parallel/test-fs-watchfile.js
Outdated
|
||
fs.writeFile(`${dir}/foo.txt`, 'foo', common.mustCall(function(err) { | ||
if (err) | ||
assert.fail(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.
Ditto
@chris--young we raised a code style nit, then this will land. |
21535c3
to
64884c2
Compare
@refack made those changes. It looks like a new test is failing now, possibly another infrastructure fail
|
Ignore it |
also added regression tests PR-URL: nodejs#13111 Fixes: nodejs#13108 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
Landed in c470f04 |
also added regression tests PR-URL: #13111 Fixes: #13108 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
also added regression tests PR-URL: #13111 Fixes: #13108 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
macOS is not currently listed as a supported os for the fs.watch filename argument, but it does work. This commit updates the documentation to reflect that.
Fixes: #13108
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
docs, tests