MCPcopy Index your code
hub / github.com/nodejs/node / test_relative_input_cwd

Function test_relative_input_cwd

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

Source from the content-addressed store, hash-verified

272}
273
274function test_relative_input_cwd(realpath, realpathSync, callback) {
275 console.log('test_relative_input_cwd');
276 if (skipSymlinks) {
277 common.printSkipMessage('symlink test (no privs)');
278 return callback();
279 }
280
281 // We need to calculate the relative path to the tmp dir from cwd
282 const entrydir = process.cwd();
283 const entry = path.relative(entrydir,
284 path.join(`${tmpDir}/cycles/realpath-3a`));
285 const expected = `${tmpDir}/cycles/root.js`;
286 [
287 [entry, '../cycles/realpath-3b'],
288 [`${tmpDir}/cycles/realpath-3b`, '../cycles/realpath-3c'],
289 [`${tmpDir}/cycles/realpath-3c`, 'root.js'],
290 ].forEach(function(t) {
291 const fn = t[0];
292 console.error('fn=%j', fn);
293 try { fs.unlinkSync(fn); } catch {
294 // Continue regardless of error.
295 }
296 const b = path.basename(t[1]);
297 const type = (b === 'root.js' ? 'file' : 'dir');
298 console.log('fs.symlinkSync(%j, %j, %j)', t[1], fn, type);
299 fs.symlinkSync(t[1], fn, 'file');
300 unlink.push(fn);
301 });
302
303 const origcwd = process.cwd();
304 process.chdir(entrydir);
305 assertEqualPath(realpathSync(entry), path.resolve(expected));
306 asynctest(realpath, [entry], callback, function(err, result) {
307 process.chdir(origcwd);
308 assertEqualPath(result, path.resolve(expected));
309 return true;
310 });
311}
312
313function test_deep_symlink_mix(realpath, realpathSync, callback) {
314 console.log('test_deep_symlink_mix');

Callers

nothing calls this directly

Calls 12

asynctestFunction · 0.85
chdirMethod · 0.80
callbackFunction · 0.70
forEachMethod · 0.65
realpathSyncFunction · 0.50
logMethod · 0.45
joinMethod · 0.45
errorMethod · 0.45
unlinkSyncMethod · 0.45
symlinkSyncMethod · 0.45
pushMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…