Skip to content
Closed
Changes from 1 commit
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
17 changes: 9 additions & 8 deletions test/parallel/test-require-symlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const fs = require('fs');
const exec = require('child_process').exec;
const spawn = require('child_process').spawn;

common.refreshTmpDir();

const linkTarget = path.join(common.fixturesDir,
'/module-require-symlink/node_modules/dep2/');

Expand All @@ -22,8 +24,8 @@ if (common.isWindows) {
// On Windows, creating symlinks requires admin privileges.
// We'll only try to run symlink test if we have enough privileges.
exec('whoami /priv', function(err, o) {
if (err || o.indexOf('SeCreateSymbolicLinkPrivilege') == -1) {
console.log('Skipped: insufficient privileges');
if (err || !o.includes('SeCreateSymbolicLinkPrivilege')) {
common.skip('Skipped: insufficient privileges');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you drop the Skipped: part.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might actually be worthwhile to lint for Skipped: in strings in tests come to think of it.

Copy link
Contributor Author

@paulgrock paulgrock Aug 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I can change it. Do you want me to revert it back to console.log or just remove this line?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep common.skip(). There is just no need to say you're skipping in skip().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words, change this:

common.skip('Skipping: insufficient privileges');

to something like this:

common.skip('insufficient privileges');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops sorry misread the initial comment by @cjihrig. Fixed now

return;
} else {
test();
Expand All @@ -36,21 +38,20 @@ if (common.isWindows) {
function test() {
process.on('exit', function() {
fs.unlinkSync(linkDir);
fs.unlinkSync(linkScript);
});

fs.symlinkSync(linkTarget, linkDir);
fs.symlinkSync(linkScriptTarget, linkScript);

// load symlinked-module
var fooModule =
const fooModule =
require(path.join(common.fixturesDir, '/module-require-symlink/foo.js'));
assert.equal(fooModule.dep1.bar.version, 'CORRECT_VERSION');
assert.equal(fooModule.dep2.bar.version, 'CORRECT_VERSION');
assert.strictEqual(fooModule.dep1.bar.version, 'CORRECT_VERSION');
assert.strictEqual(fooModule.dep2.bar.version, 'CORRECT_VERSION');

// load symlinked-script as main
var node = process.execPath;
var child = spawn(node, ['--preserve-symlinks', linkScript]);
const node = process.execPath;
const child = spawn(node, ['--preserve-symlinks', linkScript]);
child.on('close', function(code, signal) {
assert(!code);
assert(!signal);
Expand Down