Skip to content

Commit ad4bf9e

Browse files
homosaurMylesBorins
authored andcommitted
test: swap var for let/const throughout
Swap var for let/const throughout the common.js module. Change a snake case variable to camel case starting on line 168. PR-URL: #10177 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 5b2ca85 commit ad4bf9e

1 file changed

Lines changed: 25 additions & 24 deletions

File tree

‎test/common.js‎

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ exports.rootDir = exports.isWindows ? 'c:\\' : '/';
3838
exports.buildType=process.config.target_defaults.default_configuration;
3939

4040
functionrimrafSync(p){
41+
letst;
4142
try{
42-
varst=fs.lstatSync(p);
43+
st=fs.lstatSync(p);
4344
}catch(e){
4445
if(e.code==='ENOENT')
4546
return;
@@ -93,9 +94,9 @@ if (process.env.TEST_THREAD_ID) {
9394
}
9495
exports.tmpDir=path.join(testRoot,exports.tmpDirName);
9596

96-
varopensslCli=null;
97-
varinFreeBSDJail=null;
98-
varlocalhostIPv4=null;
97+
letopensslCli=null;
98+
letinFreeBSDJail=null;
99+
letlocalhostIPv4=null;
99100

100101
exports.localIPv6Hosts=['localhost'];
101102
if(exports.isLinux){
@@ -165,8 +166,8 @@ Object.defineProperty(exports, 'opensslCli', {get: function() {
165166

166167
if(exports.isWindows)opensslCli+='.exe';
167168

168-
varopenssl_cmd=child_process.spawnSync(opensslCli,['version']);
169-
if(openssl_cmd.status!==0||openssl_cmd.error!==undefined){
169+
constopensslCmd=child_process.spawnSync(opensslCli,['version']);
170+
if(opensslCmd.status!==0||opensslCmd.error!==undefined){
170171
// openssl command cannot be executed
171172
opensslCli=false;
172173
}
@@ -194,7 +195,7 @@ if (exports.isWindows) {
194195
exports.PIPE=exports.tmpDir+'/test.sock';
195196
}
196197

197-
varifaces=os.networkInterfaces();
198+
constifaces=os.networkInterfaces();
198199
exports.hasIPv6=Object.keys(ifaces).some(function(name){
199200
return/lo/.test(name)&&ifaces[name].some(function(info){
200201
returninfo.family==='IPv6';
@@ -204,7 +205,7 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) {
204205

205206
exports.ddCommand=function(filename,kilobytes){
206207
if(exports.isWindows){
207-
varp=path.resolve(exports.fixturesDir,'create-file.js');
208+
constp=path.resolve(exports.fixturesDir,'create-file.js');
208209
return'"'+process.argv[0]+'" "'+p+'" "'+
209210
filename+'" '+(kilobytes*1024);
210211
}else{
@@ -214,7 +215,7 @@ exports.ddCommand = function(filename, kilobytes) {
214215

215216

216217
exports.spawnCat=function(options){
217-
varspawn=require('child_process').spawn;
218+
constspawn=require('child_process').spawn;
218219

219220
if(exports.isWindows){
220221
returnspawn('more',[],options);
@@ -225,7 +226,7 @@ exports.spawnCat = function(options) {
225226

226227

227228
exports.spawnSyncCat=function(options){
228-
varspawnSync=require('child_process').spawnSync;
229+
constspawnSync=require('child_process').spawnSync;
229230

230231
if(exports.isWindows){
231232
returnspawnSync('more',[],options);
@@ -236,7 +237,7 @@ exports.spawnSyncCat = function(options) {
236237

237238

238239
exports.spawnPwd=function(options){
239-
varspawn=require('child_process').spawn;
240+
constspawn=require('child_process').spawn;
240241

241242
if(exports.isWindows){
242243
returnspawn('cmd.exe',['/c','cd'],options);
@@ -277,7 +278,7 @@ exports.platformTimeout = function(ms) {
277278
returnms;// ARMv8+
278279
};
279280

280-
varknownGlobals=[
281+
letknownGlobals=[
281282
Buffer,
282283
clearImmediate,
283284
clearInterval,
@@ -351,9 +352,9 @@ function allowGlobals(...whitelist) {
351352
exports.allowGlobals=allowGlobals;
352353

353354
functionleakedGlobals(){
354-
varleaked=[];
355+
constleaked=[];
355356

356-
for(varvalinglobal)
357+
for(constvalinglobal)
357358
if(!knownGlobals.includes(global[val]))
358359
leaked.push(val);
359360

@@ -366,21 +367,21 @@ exports.globalCheck = true;
366367

367368
process.on('exit',function(){
368369
if(!exports.globalCheck)return;
369-
varleaked=leakedGlobals();
370+
constleaked=leakedGlobals();
370371
if(leaked.length>0){
371372
console.error('Unknown globals: %s',leaked);
372373
fail('Unknown global found');
373374
}
374375
});
375376

376377

377-
varmustCallChecks=[];
378+
constmustCallChecks=[];
378379

379380

380381
functionrunCallChecks(exitCode){
381382
if(exitCode!==0)return;
382383

383-
varfailed=mustCallChecks.filter(function(context){
384+
constfailed=mustCallChecks.filter(function(context){
384385
returncontext.actual!==context.expected;
385386
});
386387

@@ -399,7 +400,7 @@ function runCallChecks(exitCode) {
399400
exports.mustCall=function(fn,expected){
400401
if(typeofexpected!=='number')expected=1;
401402

402-
varcontext={
403+
constcontext={
403404
expected: expected,
404405
actual: 0,
405406
stack: (newError()).stack,
@@ -418,9 +419,9 @@ exports.mustCall = function(fn, expected) {
418419
};
419420

420421
exports.hasMultiLocalhost=functionhasMultiLocalhost(){
421-
varTCP=process.binding('tcp_wrap').TCP;
422-
vart=newTCP();
423-
varret=t.bind('127.0.0.2',exports.PORT);
422+
constTCP=process.binding('tcp_wrap').TCP;
423+
constt=newTCP();
424+
constret=t.bind('127.0.0.2',exports.PORT);
424425
t.close();
425426
returnret===0;
426427
};
@@ -466,7 +467,7 @@ ArrayStream.prototype.write = function() {};
466467
exports.nodeProcessAborted=functionnodeProcessAborted(exitCode,signal){
467468
// Depending on the compiler used, node will exit with either
468469
// exit code 132 (SIGILL), 133 (SIGTRAP) or 134 (SIGABRT).
469-
varexpectedExitCodes=[132,133,134];
470+
letexpectedExitCodes=[132,133,134];
470471

471472
// On platforms using KSH as the default shell (like SmartOS),
472473
// when a process aborts, KSH exits with an exit code that is
@@ -495,8 +496,8 @@ exports.nodeProcessAborted = function nodeProcessAborted(exitCode, signal) {
495496
};
496497

497498
exports.busyLoop=functionbusyLoop(time){
498-
varstartTime=Timer.now();
499-
varstopTime=startTime+time;
499+
conststartTime=Timer.now();
500+
conststopTime=startTime+time;
500501
while(Timer.now()<stopTime){}
501502
};
502503

0 commit comments

Comments
 (0)