mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 05:11:49 +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>
25 lines
650 B
JavaScript
25 lines
650 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
var path = require('path');
|
|
var fs = require('fs');
|
|
|
|
common.refreshTmpDir();
|
|
|
|
(function() {
|
|
var file = path.join(common.tmpDir, 'write-end-test0.txt');
|
|
var stream = fs.createWriteStream(file);
|
|
stream.end();
|
|
stream.on('close', common.mustCall(function() { }));
|
|
})();
|
|
|
|
(function() {
|
|
var file = path.join(common.tmpDir, 'write-end-test1.txt');
|
|
var stream = fs.createWriteStream(file);
|
|
stream.end('a\n', 'utf8');
|
|
stream.on('close', common.mustCall(function() {
|
|
var content = fs.readFileSync(file, 'utf8');
|
|
assert.equal(content, 'a\n');
|
|
}));
|
|
})();
|