From 9359de9dd2eae06ed5afcb75dad9bd4c466eb69d Mon Sep 17 00:00:00 2001 From: Sakthipriyan Vairamani Date: Sun, 26 Jun 2016 12:04:31 +0530 Subject: fs: make callback mandatory to all async functions 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 --- test/parallel/test-fs-readfile-error.js | 34 --------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 test/parallel/test-fs-readfile-error.js (limited to 'test/parallel/test-fs-readfile-error.js') diff --git a/test/parallel/test-fs-readfile-error.js b/test/parallel/test-fs-readfile-error.js deleted file mode 100644 index 86a2be4e1b..0000000000 --- a/test/parallel/test-fs-readfile-error.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; -var common = require('../common'); -var assert = require('assert'); -var exec = require('child_process').exec; -var path = require('path'); - -// `fs.readFile('/')` does not fail on FreeBSD, because you can open and read -// the directory there. -if (process.platform === 'freebsd') { - common.skip('platform not supported.'); - return; -} - -function test(env, cb) { - var filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js'); - var execPath = '"' + process.execPath + '" "' + filename + '"'; - var options = { env: Object.assign(process.env, env) }; - exec(execPath, options, function(err, stdout, stderr) { - assert(err); - assert.equal(stdout, ''); - assert.notEqual(stderr, ''); - cb('' + stderr); - }); -} - -test({ NODE_DEBUG: '' }, common.mustCall(function(data) { - assert(/EISDIR/.test(data)); - assert(!/test-fs-readfile-error/.test(data)); -})); - -test({ NODE_DEBUG: 'fs' }, common.mustCall(function(data) { - assert(/EISDIR/.test(data)); - assert(/test-fs-readfile-error/.test(data)); -})); -- cgit v1.2.3