diff options
author | Dan Kang <dann.kang@gmail.com> | 2018-05-09 23:39:58 +0900 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-05-18 15:50:42 +0200 |
commit | 60cc8ff096c98c3bfd5c4906ac9af3e9c220a748 (patch) | |
tree | 944b6c2462f63368ae25d20beff25ecaa927c1e4 /test | |
parent | 9aa4ec43fce7fd9166459c98f347760cf450a350 (diff) | |
download | android-node-v8-60cc8ff096c98c3bfd5c4906ac9af3e9c220a748.tar.gz android-node-v8-60cc8ff096c98c3bfd5c4906ac9af3e9c220a748.tar.bz2 android-node-v8-60cc8ff096c98c3bfd5c4906ac9af3e9c220a748.zip |
src: remove 2nd `undefined` argument in node_file.cc
In the document for fs, there are several functions that state "No
arguments other than a possible exception are given to the completion
callback." (ex> fs.access, fs.chmod, fs.close, ..)
But, the functions are invoking the callback with two parameters (err,
undefined)
It causes problems in using several API like
[async.waterfall](https://caolan.github.io/async/docs.html#waterfall).
PR-URL: https://github.com/nodejs/node/pull/20629
Fixes: https://github.com/nodejs/node/issues/20335
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-fs-access.js | 12 | ||||
-rw-r--r-- | test/parallel/test-fs-close.js | 12 |
2 files changed, 21 insertions, 3 deletions
diff --git a/test/parallel/test-fs-access.js b/test/parallel/test-fs-access.js index 01dbe90eda..d053b9323b 100644 --- a/test/parallel/test-fs-access.js +++ b/test/parallel/test-fs-access.js @@ -64,15 +64,21 @@ assert.strictEqual(typeof fs.X_OK, 'number'); const throwNextTick = (e) => { process.nextTick(() => { throw e; }); }; -fs.access(__filename, common.mustCall(assert.ifError)); +fs.access(__filename, common.mustCall(function(...args) { + assert.deepStrictEqual(args, [null]); +})); fs.promises.access(__filename) .then(common.mustCall()) .catch(throwNextTick); -fs.access(__filename, fs.R_OK, common.mustCall(assert.ifError)); +fs.access(__filename, fs.R_OK, common.mustCall(function(...args) { + assert.deepStrictEqual(args, [null]); +})); fs.promises.access(__filename, fs.R_OK) .then(common.mustCall()) .catch(throwNextTick); -fs.access(readOnlyFile, fs.F_OK | fs.R_OK, common.mustCall(assert.ifError)); +fs.access(readOnlyFile, fs.F_OK | fs.R_OK, common.mustCall(function(...args) { + assert.deepStrictEqual(args, [null]); +})); fs.promises.access(readOnlyFile, fs.F_OK | fs.R_OK) .then(common.mustCall()) .catch(throwNextTick); diff --git a/test/parallel/test-fs-close.js b/test/parallel/test-fs-close.js new file mode 100644 index 0000000000..da0d0dfdc8 --- /dev/null +++ b/test/parallel/test-fs-close.js @@ -0,0 +1,12 @@ +'use strict'; + +const common = require('../common'); + +const assert = require('assert'); +const fs = require('fs'); + +const fd = fs.openSync(__filename, 'r'); + +fs.close(fd, common.mustCall(function(...args) { + assert.deepStrictEqual(args, [null]); +})); |