Skip to content

Commit 4477e15

Browse files
clarencedItalo A. Casas
authored andcommitted
test: add regex in test_cyclic_link_protection
PR-URL: #11622 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 3d55cf0 commit 4477e15

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

‎test/parallel/test-fs-realpath.js‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,21 +191,25 @@ function test_cyclic_link_protection(callback) {
191191
common.skip('symlink test (no privs)');
192192
returnrunNextTest();
193193
}
194-
constentry=common.tmpDir+'/cycles/realpath-3a';
194+
constentry=path.join(common.tmpDir,'/cycles/realpath-3a');
195195
[
196196
[entry,'../cycles/realpath-3b'],
197-
[common.tmpDir+'/cycles/realpath-3b','../cycles/realpath-3c'],
198-
[common.tmpDir+'/cycles/realpath-3c','../cycles/realpath-3a']
197+
[path.join(common.tmpDir,'/cycles/realpath-3b'),'../cycles/realpath-3c'],
198+
[path.join(common.tmpDir,'/cycles/realpath-3c'),'../cycles/realpath-3a']
199199
].forEach(function(t){
200200
try{fs.unlinkSync(t[0]);}catch(e){}
201201
fs.symlinkSync(t[1],t[0],'dir');
202202
unlink.push(t[0]);
203203
});
204-
assert.throws(function(){fs.realpathSync(entry);});
205-
asynctest(fs.realpath,[entry],callback,function(err,result){
206-
assert.ok(err&&true);
207-
returntrue;
208-
});
204+
assert.throws(()=>{
205+
fs.realpathSync(entry);
206+
},common.expectsError({code: 'ELOOP',type: Error}));
207+
asynctest(
208+
fs.realpath,[entry],callback,common.mustCall(function(err,result){
209+
assert.strictEqual(err.path,entry);
210+
assert.strictEqual(result,undefined);
211+
returntrue;
212+
}));
209213
}
210214

211215
functiontest_cyclic_link_overprotection(callback){

0 commit comments

Comments
 (0)