summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-watchfile.js
AgeCommit message (Collapse)Author
2019-11-19fs: make FSStatWatcher.start privateLucas Holmquist
An instance of FSStatWatcher is returned when a user calls fs.watchFile, which will call the start method. A user can't create an instance of a FSStatWatcher directly. If the start method is called by a user it is a noop since the watcher has already started. This "Class" is currently undocumented. PR-URL: https://github.com/nodejs/node/pull/29971 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-02-28benchmark,doc,lib,test: capitalize commentsRuben Bridgewater
This updates a lot of comments. PR-URL: https://github.com/nodejs/node/pull/26223 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
2019-02-15fs, src, lib: fix `blksize` & `blocks` on WindowsRichard Lau
libuv returns values for `blksize` and `blocks` on stat calls so do not coerce them into `undefined` on Windows. PR-URL: https://github.com/nodejs/node/pull/26056 Fixes: https://github.com/nodejs/node/issues/25913 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-19fs: improve errors in watchFile and unwatchFileJoyee Cheung
- Check if the watcher is active in JS land before invoking the binding, act as a noop if the state of the watcher does not match the expectation. This avoids firing 'stop' when the watcher is already stopped. - Update comments, validate more arguments and the type of the handle. - Handle the errors from uv_fs_poll_start - Create an `IsActive` helper method on StatWatcher PR-URL: https://github.com/nodejs/node/pull/19345 Refs: https://github.com/nodejs/node/pull/19089 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-01-31test: move tmpdir to submodule of commonRich Trott
Move tmpdir functionality to its own module (common/tmpdir). PR-URL: https://github.com/nodejs/node/pull/17856 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2017-12-13src: make FSEventWrap/StatWatcher::Start more robustTimothy Gu
PR-URL: https://github.com/nodejs/node/pull/17432 Fixes: https://github.com/nodejs/node/issues/17430 Reviewed-By: James M Snell <jasnell@gmail.com>
2017-12-08test: replace assert.throws w/ common.expectsErrorMithun Sasidharan
PR-URL: https://github.com/nodejs/node/pull/17497 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-08-31errors: convert 'fs'matzavinos
covert lib/fs.js over to using lib/internal/errors.js i have not addressed the cases that use errnoException(), for reasons described in GH-12926 - throw the ERR_INVALID_CALLBACK error when the the callback is invalid - replace the ['object', 'string'] with ['string', 'object'] in the error constructor call, to better match the previous err msg in the getOptions() function - add error ERR_VALUE_OUT_OF_RANGE in lib/internal/errors.js, this error is thrown when a numeric value is out of range - document the ERR_VALUE_OUT_OF_RANGE err in errors.md - correct the expected args, in the error thrown in the function fs._toUnixTimestamp() to ['Date', 'time in seconds'] (lib/fs.js) - update the listener error type in the fs.watchFile() function, from Error to TypeError (lib/fs.js) - update errors from ERR_INVALID_OPT_VALUE to ERR_INVALID_ARG_TYPE in the functions fs.ReadStream() and fs.WriteStream(), for the cases of range errors use the new error: ERR_VALUE_OUT_OF_RANGE (lib/fs.js) PR-URL: https://github.com/nodejs/node/pull/15043 Refs: https://github.com/nodejs/node/issues/11273 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-07-27test: adjust indentation for stricter lintingRich Trott
ESLint 4.x has stricter linting than previous versions. We are currently using the legacy indentation rules in the test directory. This commit changes the indentation of files to comply with the stricter 4.x linting and enable stricter linting in the test directory. PR-URL: https://github.com/nodejs/node/pull/14431 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2017-07-21lib,src: fix consistent spacing inside bracesSebastiaan Deckers
PR-URL: https://github.com/nodejs/node/pull/14162 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-07-19test: replace string concat in test-fs-watchfile.jsHelianthus21
PR-URL: https://github.com/nodejs/node/pull/14287 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-06-19test: refactor test-fs-watchfileRich Trott
* use `common.mustNotCall()` to confirm callback is not called * reorder modules to conform with test-writing guide * match full error message in `assert.throws()` PR-URL: https://github.com/nodejs/node/pull/13721 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-06-06path: use internal/errors.jsSebastian Van Sande
PR-URL: https://github.com/nodejs/node/pull/11319 Ref: https://github.com/nodejs/node/issues/11273 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-06-02test: make test-fs-watchfile reliableRich Trott
Omitting AIX from `fs.watch()` portion of this test. It works on AIX, but not reliably. PR-URL: https://github.com/nodejs/node/pull/13385 Fixes: https://github.com/nodejs/node/issues/13377 Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-05-30test: fix flaky test-fs-watchfile on macOSRich Trott
On macOS, a watcher created with fs.watch() does not necessarily start receiving events immediately. So it can miss a change by fs.writefile() if it comes very soon after the watcher is created. Fix test flakiness caused by this by using `setInterval()` to repeat the write action. PR-URL: https://github.com/nodejs/node/pull/13252 Fixes: https://github.com/nodejs/node/issues/13248 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-05-22doc: list macOS as supporting filename argumentChris Young
also added regression tests PR-URL: https://github.com/nodejs/node/pull/13111 Fixes: https://github.com/nodejs/node/issues/13108 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
2017-03-26test: add common.noop, default for common.mustCall()James M Snell
Export a new common.noop no-operation function for general use. Allow using common.mustCall() without a fn argument to simplify test cases. Replace various non-op functions throughout tests with common.noop PR-URL: https://github.com/nodejs/node/pull/12027 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2017-01-11test: use eslint to fix var->const/letGibson Fahnestock
Manually fix issues that eslint --fix couldn't do automatically. PR-URL: https://github.com/nodejs/node/pull/10685 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
2016-08-05Revert "fs: make callback mandatory to all async functions"Myles Borins
This reverts commit 9359de9dd2eae06ed5afcb75dad9bd4c466eb69d. Original Commit Message: The "fs" module has two functions called `maybeCallback` and `makeCallback`, as of now. The `maybeCallback` creates a default function to report errors, if the parameter passed is not a function object. Basically, if the callback is omitted in some cases, this function is used to create a default callback function. The `makeCallback`, OTOH, creates a default function only if the parameter passed is `undefined`, and if it is not a function object it will throw an `Error`. This patch removes the `maybeCallback` function and makes the callback function argument mandatory for all the async functions. PR-URL: https://github.com/nodejs/node/pull/7168 Reviewed-By: Trevor Norris <trev.norris@gmail.com> PR-URL: https://github.com/nodejs/node/pull/7846 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-07-22fs: make callback mandatory to all async functionsSakthipriyan Vairamani
The "fs" module has two functions called `maybeCallback` and `makeCallback`, as of now. The `maybeCallback` creates a default function to report errors, if the parameter passed is not a function object. Basically, if the callback is omitted in some cases, this function is used to create a default callback function. The `makeCallback`, OTOH, creates a default function only if the parameter passed is `undefined`, and if it is not a function object it will throw an `Error`. This patch removes the `maybeCallback` function and makes the callback function argument mandatory for all the async functions. PR-URL: https://github.com/nodejs/node/pull/7168 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-11-10test: fix tests that check error messagescjihrig
20285ad17755187ece16b8a5effeaa87f5407da2 changed the format of error messages throughout lib. However, the tests were not updated to reflect these changes. This commit makes those changes. PR-URL: https://github.com/nodejs/node/pull/3727 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: James M Snell <jasnell@gmail.com>
2015-08-18test: refactor test-fs-watchfile.jsRich Trott
The test no longer waits about 5 seconds between callback invocations. It now writes to the tmp directory rather than the fixtures directory. Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> PR-URL: https://github.com/nodejs/node/pull/2393
2015-08-04doc,test: documents behaviour of non-existent fileSakthipriyan Vairamani
As per the discussion in https://github.com/nodejs/io.js/pull/2093#discussion_r34343965, this patch documents the behavior of calling fs.watchFile() with a path that does not yet exist. This patch also includes a test which checks if a file not present, the callback is invoked at least once and if the file is created after the callback is invoked, it will be invoked again with new stat objects. PR-URL: https://github.com/nodejs/io.js/pull/2169 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-07-10doc: document fs.watchFile behaviour on ENOENTBrendan Ashworth
When fs.watchFile encounters an ENOENT error, it invokes the given callback with some error data. This caused an issue as it was different behaviour than Node v0.10. Instead of changing this behaviour, document it and add a test. Ref: https://github.com/nodejs/io.js/issues/1745 Ref: https://github.com/nodejs/io.js/pull/2028 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> PR-URL: https://github.com/nodejs/io.js/pull/2093
2015-07-10fs: fix error on bad listener typeBrendan Ashworth
When the listener was truthy but NOT a function, fs.watchFile would throw an error through the EventEmitter. This caused a problem because it would only be thrown after the listener was started, which left the listener on. There should be no backwards compatability issues because the error was always thrown, just in a different manner. Also adds tests for this and other basic functionality. PR-URL: https://github.com/nodejs/io.js/pull/2093 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>