Skip to content

Commit

Permalink
fs: check for symlink support in fs-promises test
Browse files Browse the repository at this point in the history
Attempting to make symlinks as a non-administrator user in Windows
causes a permission error. We need to update test-fs-promises to avoid
making symlinks if the platform does not support it.

PR-URL: #19018
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Shingo Inoue <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
sethbrenith authored and Leko committed Mar 3, 2018
1 parent 67b5985 commit 96b2d8d
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions test/parallel/test-fs-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,24 @@ function verifyStatObject(stat) {
stats = await stat(newPath);
verifyStatObject(stats);

const newLink = path.resolve(tmpDir, 'baz3.js');
await symlink(newPath, newLink);
if (common.canCreateSymLink()) {
const newLink = path.resolve(tmpDir, 'baz3.js');
await symlink(newPath, newLink);

const newLink2 = path.resolve(tmpDir, 'baz4.js');
await link(newPath, newLink2);
stats = await lstat(newLink);
verifyStatObject(stats);

stats = await lstat(newLink);
verifyStatObject(stats);
assert.strictEqual(newPath.toLowerCase(),
(await realpath(newLink)).toLowerCase());
assert.strictEqual(newPath.toLowerCase(),
(await readlink(newLink)).toLowerCase());

assert.strictEqual(newPath.toLowerCase(),
(await realpath(newLink)).toLowerCase());
assert.strictEqual(newPath.toLowerCase(),
(await readlink(newLink)).toLowerCase());
await unlink(newLink);
}

const newLink2 = path.resolve(tmpDir, 'baz4.js');
await link(newPath, newLink2);

await unlink(newLink);
await unlink(newLink2);

const newdir = path.resolve(tmpDir, 'dir');
Expand Down

0 comments on commit 96b2d8d

Please sign in to comment.