mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 03:12:57 +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>
24 lines
528 B
JavaScript
24 lines
528 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
var path = require('path');
|
|
var fs = require('fs');
|
|
var fn = path.join(common.tmpDir, 'write.txt');
|
|
|
|
common.refreshTmpDir();
|
|
|
|
var foo = 'foo';
|
|
var fd = fs.openSync(fn, 'w');
|
|
|
|
var written = fs.writeSync(fd, '');
|
|
assert.strictEqual(0, written);
|
|
|
|
fs.writeSync(fd, foo);
|
|
|
|
var bar = 'bár';
|
|
written = fs.writeSync(fd, new Buffer(bar), 0, Buffer.byteLength(bar));
|
|
assert.ok(written > 3);
|
|
fs.closeSync(fd);
|
|
|
|
assert.equal(fs.readFileSync(fn), 'foobár');
|