MCPcopy Create free account
hub / github.com/nodejs/node / test_deep_symlink_mix

Function test_deep_symlink_mix

test/parallel/test-fs-realpath.js:313–368  ·  view source on GitHub ↗
(realpath, realpathSync, callback)

Source from the content-addressed store, hash-verified

311}
312
313function test_deep_symlink_mix(realpath, realpathSync, callback) {
314 console.log('test_deep_symlink_mix');
315 if (common.isWindows) {
316 // This one is a mix of files and directories, and it's quite tricky
317 // to get the file/dir links sorted out correctly.
318 common.printSkipMessage('symlink test (no privs)');
319 return callback();
320 }
321
322 // /tmp/node-test-realpath-f1 -> $tmpDir/node-test-realpath-d1/foo
323 // /tmp/node-test-realpath-d1 -> $tmpDir/node-test-realpath-d2
324 // /tmp/node-test-realpath-d2/foo -> $tmpDir/node-test-realpath-f2
325 // /tmp/node-test-realpath-f2
326 // -> $tmpDir/targets/nested-index/one/realpath-c
327 // $tmpDir/targets/nested-index/one/realpath-c
328 // -> $tmpDir/targets/nested-index/two/realpath-c
329 // $tmpDir/targets/nested-index/two/realpath-c -> $tmpDir/cycles/root.js
330 // $tmpDir/targets/cycles/root.js (hard)
331
332 const entry = tmp('node-test-realpath-f1');
333 try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch {
334 // Continue regardless of error.
335 }
336 try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch {
337 // Continue regardless of error.
338 }
339 fs.mkdirSync(tmp('node-test-realpath-d2'), 0o700);
340 try {
341 [
342 [entry, `${tmpDir}/node-test-realpath-d1/foo`],
343 [tmp('node-test-realpath-d1'),
344 `${tmpDir}/node-test-realpath-d2`],
345 [tmp('node-test-realpath-d2/foo'), '../node-test-realpath-f2'],
346 [tmp('node-test-realpath-f2'),
347 `${targetsAbsDir}/nested-index/one/realpath-c`],
348 [`${targetsAbsDir}/nested-index/one/realpath-c`,
349 `${targetsAbsDir}/nested-index/two/realpath-c`],
350 [`${targetsAbsDir}/nested-index/two/realpath-c`,
351 `${tmpDir}/cycles/root.js`],
352 ].forEach(function(t) {
353 try { fs.unlinkSync(t[0]); } catch {
354 // Continue regardless of error.
355 }
356 fs.symlinkSync(t[1], t[0]);
357 unlink.push(t[0]);
358 });
359 } finally {
360 unlink.push(tmp('node-test-realpath-d2'));
361 }
362 const expected = `${tmpAbsDir}/cycles/root.js`;
363 assertEqualPath(realpathSync(entry), path.resolve(expected));
364 asynctest(realpath, [entry], callback, function(err, result) {
365 assertEqualPath(result, path.resolve(expected));
366 return true;
367 });
368}
369
370function test_non_symlinks(realpath, realpathSync, callback) {

Callers

nothing calls this directly

Calls 12

asynctestFunction · 0.85
callbackFunction · 0.70
tmpFunction · 0.70
forEachMethod · 0.65
realpathSyncFunction · 0.50
logMethod · 0.45
unlinkSyncMethod · 0.45
rmdirSyncMethod · 0.45
mkdirSyncMethod · 0.45
symlinkSyncMethod · 0.45
pushMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected