mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 18:02:21 +00:00

Expose `common.refreshTmpDir()` and only call it for tests that use common.tmpDir or common.PIPE. A positive side effect is the removal of a code smell where child processes were detected by the presence of `.send()`. Now each process can decide for itself if it needs to refresh tmpDir. PR-URL: https://github.com/nodejs/io.js/pull/1954 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
var path = require('path');
|
|
var fs = require('fs');
|
|
var completed = 0;
|
|
var expected_tests = 4;
|
|
|
|
// test creating and reading symbolic link
|
|
var linkData = path.join(common.fixturesDir, 'cycles/');
|
|
var linkPath = path.join(common.tmpDir, 'cycles_link');
|
|
|
|
common.refreshTmpDir();
|
|
|
|
console.log('linkData: ' + linkData);
|
|
console.log('linkPath: ' + linkPath);
|
|
|
|
fs.symlink(linkData, linkPath, 'junction', function(err) {
|
|
if (err) throw err;
|
|
completed++;
|
|
|
|
fs.lstat(linkPath, function(err, stats) {
|
|
if (err) throw err;
|
|
assert.ok(stats.isSymbolicLink());
|
|
completed++;
|
|
|
|
fs.readlink(linkPath, function(err, destination) {
|
|
if (err) throw err;
|
|
assert.equal(destination, linkData);
|
|
completed++;
|
|
|
|
fs.unlink(linkPath, function(err) {
|
|
if (err) throw err;
|
|
assert(!common.fileExists(linkPath));
|
|
assert(common.fileExists(linkData));
|
|
completed++;
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(completed, expected_tests);
|
|
});
|
|
|