Skip to content

Commit eca9e72

Browse files
clarencedMylesBorins
authored andcommitted
test: add regex in test_cyclic_link_protection
PR-URL: #11622 Backport-PR-URL: #13785 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 6020e72 commit eca9e72

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

test/parallel/test-fs-realpath.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,21 +190,25 @@ function test_cyclic_link_protection(callback) {
190190
common.skip('symlink test (no privs)');
191191
return runNextTest();
192192
}
193-
const entry = common.tmpDir + '/cycles/realpath-3a';
193+
const entry = path.join(common.tmpDir, '/cycles/realpath-3a');
194194
[
195195
[entry, '../cycles/realpath-3b'],
196-
[common.tmpDir + '/cycles/realpath-3b', '../cycles/realpath-3c'],
197-
[common.tmpDir + '/cycles/realpath-3c', '../cycles/realpath-3a']
196+
[path.join(common.tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'],
197+
[path.join(common.tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a']
198198
].forEach(function(t) {
199199
try { fs.unlinkSync(t[0]); } catch (e) {}
200200
fs.symlinkSync(t[1], t[0], 'dir');
201201
unlink.push(t[0]);
202202
});
203-
assert.throws(function() { fs.realpathSync(entry); });
204-
asynctest(fs.realpath, [entry], callback, function(err, result) {
205-
assert.ok(err && true);
206-
return true;
207-
});
203+
assert.throws(() => {
204+
fs.realpathSync(entry);
205+
}, /^Error: ELOOP: too many symbolic links encountered, stat /);
206+
asynctest(
207+
fs.realpath, [entry], callback, common.mustCall(function(err, result) {
208+
assert.strictEqual(err.path, entry);
209+
assert.strictEqual(result, undefined);
210+
return true;
211+
}));
208212
}
209213

210214
function test_cyclic_link_overprotection(callback) {

0 commit comments

Comments
 (0)