Skip to content

Commit f333062

Browse files
edsadrMylesBorins
authored andcommitted
test: improve code in test-fs-readfile-error
* use const instead of var * use common.mustCall to control the functions execution automatically * use assert.strictEqual instead of assert.equal * use assert.notStrictEqual instead of assert.notEqual * use arrow functions PR-URL: #10367 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 67bc2ad commit f333062

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed
+13-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var exec = require('child_process').exec;
5-
var path = require('path');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const exec = require('child_process').exec;
5+
const path = require('path');
66

77
// `fs.readFile('/')` does not fail on FreeBSD, because you can open and read
88
// the directory there.
@@ -12,23 +12,23 @@ if (process.platform === 'freebsd') {
1212
}
1313

1414
function test(env, cb) {
15-
var filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js');
16-
var execPath = '"' + process.execPath + '" "' + filename + '"';
17-
var options = { env: Object.assign(process.env, env) };
18-
exec(execPath, options, function(err, stdout, stderr) {
15+
const filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js');
16+
const execPath = '"' + process.execPath + '" "' + filename + '"';
17+
const options = { env: Object.assign(process.env, env) };
18+
exec(execPath, options, common.mustCall((err, stdout, stderr) => {
1919
assert(err);
20-
assert.equal(stdout, '');
21-
assert.notEqual(stderr, '');
20+
assert.strictEqual(stdout, '');
21+
assert.notStrictEqual(stderr, '');
2222
cb('' + stderr);
23-
});
23+
}));
2424
}
2525

26-
test({ NODE_DEBUG: '' }, common.mustCall(function(data) {
26+
test({ NODE_DEBUG: '' }, common.mustCall((data) => {
2727
assert(/EISDIR/.test(data));
2828
assert(!/test-fs-readfile-error/.test(data));
2929
}));
3030

31-
test({ NODE_DEBUG: 'fs' }, common.mustCall(function(data) {
31+
test({ NODE_DEBUG: 'fs' }, common.mustCall((data) => {
3232
assert(/EISDIR/.test(data));
3333
assert(/test-fs-readfile-error/.test(data));
3434
}));

0 commit comments

Comments
 (0)