Skip to content

Commit

Permalink
test: confirm symlink
Browse files Browse the repository at this point in the history
PR-URL: #2014
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
Trott committed Jun 20, 2015
1 parent 3ba4f71 commit b0990ef
Showing 1 changed file with 19 additions and 4 deletions.
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);
});

0 comments on commit b0990ef

Please sign in to comment.