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: confirm symlink #2014

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 19 additions & 4 deletions test/parallel/test-fs-symlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ var path = require('path');
var fs = require('fs');
var exec = require('child_process').exec;
var completed = 0;
var expected_tests = 2;
var expected_async = 4;
var linkTime;
var fileTime;

var is_windows = process.platform === 'win32';

Expand All @@ -20,7 +22,19 @@ var runtest = function(skip_symlinks) {
fs.symlink(linkData, linkPath, function(err) {
if (err) throw err;
console.log('symlink done');
// todo: fs.lstat?

fs.lstat(linkPath, function(err, stats) {
if (err) throw err;
linkTime = stats.mtime.getTime();
completed++;
});

fs.stat(linkPath, function(err, stats) {
if (err) throw err;
fileTime = stats.mtime.getTime();
completed++;
});

fs.readlink(linkPath, function(err, destination) {
if (err) throw err;
assert.equal(destination, linkData);
Expand Down Expand Up @@ -48,7 +62,7 @@ if (is_windows) {
// 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) {
expected_tests = 1;
expected_async = 1;
runtest(true);
} else {
runtest(false);
Expand All @@ -59,6 +73,7 @@ if (is_windows) {
}

process.on('exit', function() {
assert.equal(completed, expected_tests);
assert.equal(completed, expected_async);
assert(linkTime !== fileTime);
});