Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: use common.canCreateSymLink() consistently #20540

Merged
merged 1 commit into from
May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions test/parallel/test-fs-realpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ const tmpdir = require('../common/tmpdir');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const exec = require('child_process').exec;
let async_completed = 0;
let async_expected = 0;
const unlink = [];
let skipSymlinks = false;
const skipSymlinks = !common.canCreateSymLink();
const tmpDir = tmpdir.path;

tmpdir.refresh();
Expand All @@ -45,25 +44,9 @@ if (common.isWindows) {
assert
.strictEqual(path_left.toLowerCase(), path_right.toLowerCase(), message);
};

// On Windows, creating symlinks requires admin privileges.
// We'll only try to run symlink test if we have enough privileges.
try {
exec('whoami /priv', function(err, o) {
if (err || !o.includes('SeCreateSymbolicLinkPrivilege')) {
skipSymlinks = true;
}
runTest();
});
} catch (er) {
// better safe than sorry
skipSymlinks = true;
process.nextTick(runTest);
}
} else {
process.nextTick(runTest);
}

process.nextTick(runTest);

function tmp(p) {
return path.join(tmpDir, p);
Expand Down
17 changes: 2 additions & 15 deletions test/parallel/test-trace-events-fs-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,8 @@ const traceFile = 'node_trace.1.log';

let gid = 1;
let uid = 1;
let skipSymlinks = false;

// On Windows, creating symlinks requires admin privileges.
// We'll check if we have enough privileges.
if (common.isWindows) {
try {
const o = cp.execSync('whoami /priv');
if (!o.includes('SeCreateSymbolicLinkPrivilege')) {
skipSymlinks = true;
}
} catch (er) {
// better safe than sorry
skipSymlinks = true;
}
} else {
if (!common.isWindows) {
gid = process.getgid();
uid = process.getuid();
}
Expand Down Expand Up @@ -111,7 +98,7 @@ tests['fs.sync.write'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +

// On windows, we need permissions to test symlink and readlink.
// We'll only try to run these tests if we have enough privileges.
if (!skipSymlinks) {
if (common.canCreateSymLink()) {
tests['fs.sync.symlink'] = 'fs.writeFileSync("fs.txt", "123", "utf8");' +
'fs.symlinkSync("fs.txt", "linkx");' +
'fs.unlinkSync("linkx");' +
Expand Down