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

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
2-
varcommon=require('../common');
3-
varassert=require('assert');
4-
varexec=require('child_process').exec;
5-
varpath=require('path');
2+
constcommon=require('../common');
3+
constassert=require('assert');
4+
constexec=require('child_process').exec;
5+
constpath=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
functiontest(env,cb){
15-
varfilename=path.join(common.fixturesDir,'test-fs-readfile-error.js');
16-
varexecPath='"'+process.execPath+'" "'+filename+'"';
17-
varoptions={env: Object.assign(process.env,env)};
18-
exec(execPath,options,function(err,stdout,stderr){
15+
constfilename=path.join(common.fixturesDir,'test-fs-readfile-error.js');
16+
constexecPath='"'+process.execPath+'" "'+filename+'"';
17+
constoptions={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)