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

Function test_abs_with_kids

test/parallel/test-fs-realpath.js:491–544  ·  view source on GitHub ↗
(realpath, realpathSync, cb)

Source from the content-addressed store, hash-verified

489// `-- link -> /tmp/node-test-realpath-abs-kids/a/b/
490// realpath(root+'/a/link/c/x.txt') ==> root+'/a/b/c/x.txt'
491function test_abs_with_kids(realpath, realpathSync, cb) {
492 console.log('test_abs_with_kids');
493
494 // This one should still run, even if skipSymlinks is set,
495 // because it uses a junction.
496 const type = skipSymlinks ? 'junction' : 'dir';
497
498 console.log('using type=%s', type);
499
500 const root = `${tmpAbsDir}/node-test-realpath-abs-kids`;
501 function cleanup() {
502 ['/a/b/c/x.txt',
503 '/a/link',
504 ].forEach(function(file) {
505 try { fs.unlinkSync(root + file); } catch {
506 // Continue regardless of error.
507 }
508 });
509 ['/a/b/c',
510 '/a/b',
511 '/a',
512 '',
513 ].forEach(function(folder) {
514 try { fs.rmdirSync(root + folder); } catch {
515 // Continue regardless of error.
516 }
517 });
518 }
519
520 function setup() {
521 cleanup();
522 ['',
523 '/a',
524 '/a/b',
525 '/a/b/c',
526 ].forEach(function(folder) {
527 console.log(`mkdir ${root}${folder}`);
528 fs.mkdirSync(root + folder, 0o700);
529 });
530 fs.writeFileSync(`${root}/a/b/c/x.txt`, 'foo');
531 fs.symlinkSync(`${root}/a/b`, `${root}/a/link`, type);
532 }
533 setup();
534 const linkPath = `${root}/a/link/c/x.txt`;
535 const expectPath = `${root}/a/b/c/x.txt`;
536 const actual = realpathSync(linkPath);
537 // console.log({link:linkPath,expect:expectPath,actual:actual},'sync');
538 assertEqualPath(actual, path.resolve(expectPath));
539 asynctest(realpath, [linkPath], cb, function(er, actual) {
540 // console.log({link:linkPath,expect:expectPath,actual:actual},'async');
541 assertEqualPath(actual, path.resolve(expectPath));
542 cleanup();
543 });
544}
545
546function test_root(realpath, realpathSync, cb) {
547 assertEqualPath(root, realpathSync('/'));

Callers

nothing calls this directly

Calls 6

asynctestFunction · 0.85
setupFunction · 0.70
cleanupFunction · 0.70
realpathSyncFunction · 0.50
logMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected