mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 23:43:09 +01:00
7c79490bfb
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>
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
var path = require('path');
|
|
var fs = require('fs');
|
|
|
|
common.refreshTmpDir();
|
|
|
|
var dirname = path.dirname(__filename);
|
|
var d = path.join(common.tmpDir, 'dir');
|
|
|
|
var mkdir_error = false;
|
|
var rmdir_error = false;
|
|
|
|
fs.mkdir(d, 0o666, function(err) {
|
|
if (err) {
|
|
console.log('mkdir error: ' + err.message);
|
|
mkdir_error = true;
|
|
} else {
|
|
fs.mkdir(d, 0o666, function(err) {
|
|
console.log('expect EEXIST error: ', err);
|
|
assert.ok(err.message.match(/^EEXIST/), 'got EEXIST message');
|
|
assert.equal(err.code, 'EEXIST', 'got EEXIST code');
|
|
assert.equal(err.path, d, 'got proper path for EEXIST');
|
|
|
|
console.log('mkdir okay!');
|
|
fs.rmdir(d, function(err) {
|
|
if (err) {
|
|
console.log('rmdir error: ' + err.message);
|
|
rmdir_error = true;
|
|
} else {
|
|
console.log('rmdir okay!');
|
|
}
|
|
});
|
|
});
|
|
}
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(false, mkdir_error);
|
|
assert.equal(false, rmdir_error);
|
|
console.log('exit');
|
|
});
|