Browse Source

test: only refresh tmpDir for tests that need it

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>
v2.3.1-release
Rich Trott 10 years ago
parent
commit
7c79490bfb
  1. 1
      .eslintignore
  2. 22
      test/common.js
  3. 2
      test/fixtures/listen-on-socket-and-exit.js
  4. 1
      test/parallel/test-child-process-fork-exec-path.js
  5. 1
      test/parallel/test-cluster-http-pipe.js
  6. 1
      test/parallel/test-cwd-enoent-repl.js
  7. 1
      test/parallel/test-cwd-enoent.js
  8. 1
      test/parallel/test-file-write-stream.js
  9. 2
      test/parallel/test-file-write-stream2.js
  10. 2
      test/parallel/test-file-write-stream3.js
  11. 1
      test/parallel/test-fs-access.js
  12. 2
      test/parallel/test-fs-append-file-sync.js
  13. 2
      test/parallel/test-fs-append-file.js
  14. 4
      test/parallel/test-fs-chmod.js
  15. 7
      test/parallel/test-fs-long-path.js
  16. 2
      test/parallel/test-fs-mkdir.js
  17. 1
      test/parallel/test-fs-read-stream-fd.js
  18. 1
      test/parallel/test-fs-readfile-pipe-large.js
  19. 1
      test/parallel/test-fs-readfilesync-pipe-large.js
  20. 5
      test/parallel/test-fs-realpath.js
  21. 6
      test/parallel/test-fs-sir-writes-alot.js
  22. 2
      test/parallel/test-fs-stream-double-close.js
  23. 5
      test/parallel/test-fs-symlink-dir-junction-relative.js
  24. 5
      test/parallel/test-fs-symlink-dir-junction.js
  25. 12
      test/parallel/test-fs-symlink.js
  26. 2
      test/parallel/test-fs-truncate-GH-6233.js
  27. 3
      test/parallel/test-fs-truncate-fd.js
  28. 2
      test/parallel/test-fs-truncate.js
  29. 2
      test/parallel/test-fs-write-buffer.js
  30. 2
      test/parallel/test-fs-write-file-buffer.js
  31. 20
      test/parallel/test-fs-write-file-sync.js
  32. 2
      test/parallel/test-fs-write-file.js
  33. 2
      test/parallel/test-fs-write-stream-change-open.js
  34. 2
      test/parallel/test-fs-write-stream-encoding.js
  35. 2
      test/parallel/test-fs-write-stream-end.js
  36. 2
      test/parallel/test-fs-write-stream-err.js
  37. 2
      test/parallel/test-fs-write-stream-throw-type-error.js
  38. 2
      test/parallel/test-fs-write-stream.js
  39. 3
      test/parallel/test-fs-write-string-coerce.js
  40. 1
      test/parallel/test-fs-write-sync.js
  41. 2
      test/parallel/test-fs-write.js
  42. 2
      test/parallel/test-http-curl-chunk-problem.js
  43. 2
      test/parallel/test-http-get-pipeline-problem.js
  44. 2
      test/parallel/test-http-pipe-fs.js
  45. 2
      test/parallel/test-https-truncate.js
  46. 2
      test/parallel/test-pipe-file-to-http.js
  47. 2
      test/parallel/test-repl-.save.load.js
  48. 2
      test/parallel/test-zlib-from-gzip.js
  49. 2
      test/sequential/test-fs-watch-recursive.js
  50. 6
      test/sequential/test-fs-watch.js
  51. 2
      test/sequential/test-mkdir-rmdir.js
  52. 2
      test/sequential/test-regress-GH-4027.js
  53. 2
      test/sequential/test-stdout-to-file.js

1
.eslintignore

@ -4,3 +4,4 @@ test/fixtures
test/**/node_modules test/**/node_modules
test/parallel/test-fs-non-number-arguments-throw.js test/parallel/test-fs-non-number-arguments-throw.js
test/disabled test/disabled
test/tmp*/

22
test/common.js

@ -51,19 +51,17 @@ function rmdirSync(p, originalEr) {
} }
} }
function refreshTmpDir() { exports.refreshTmpDir = function() {
if (!process.send) { // Not a child process try {
try { rimrafSync(exports.tmpDir);
rimrafSync(exports.tmpDir); } catch (e) {
} catch (e) { }
}
try { try {
fs.mkdirSync(exports.tmpDir); fs.mkdirSync(exports.tmpDir);
} catch (e) { } catch (e) {
}
} }
} };
if (process.env.TEST_THREAD_ID) { if (process.env.TEST_THREAD_ID) {
// Distribute ports in parallel tests // Distribute ports in parallel tests
@ -74,8 +72,6 @@ if (process.env.TEST_THREAD_ID) {
} }
exports.tmpDir = path.join(exports.testDir, exports.tmpDirName); exports.tmpDir = path.join(exports.testDir, exports.tmpDirName);
refreshTmpDir();
var opensslCli = null; var opensslCli = null;
var inFreeBSDJail = null; var inFreeBSDJail = null;
var localhostIPv4 = null; var localhostIPv4 = null;

2
test/fixtures/listen-on-socket-and-exit.js

@ -3,6 +3,8 @@
var common = require('../common'); var common = require('../common');
var net = require('net'); var net = require('net');
common.refreshTmpDir();
var server = net.createServer().listen(common.PIPE, function() { var server = net.createServer().listen(common.PIPE, function() {
console.log('child listening'); console.log('child listening');
process.send('listening'); process.send('listening');

1
test/parallel/test-child-process-fork-exec-path.js

@ -15,6 +15,7 @@ if (process.env.FORK) {
process.exit(); process.exit();
} }
else { else {
common.refreshTmpDir();
try { try {
fs.unlinkSync(copyPath); fs.unlinkSync(copyPath);
} }

1
test/parallel/test-cluster-http-pipe.js

@ -10,6 +10,7 @@ var cluster = require('cluster');
var http = require('http'); var http = require('http');
if (cluster.isMaster) { if (cluster.isMaster) {
common.refreshTmpDir();
var ok = false; var ok = false;
var worker = cluster.fork(); var worker = cluster.fork();
worker.on('message', function(msg) { worker.on('message', function(msg) {

1
test/parallel/test-cwd-enoent-repl.js

@ -11,6 +11,7 @@ if (process.platform === 'sunos' || process.platform === 'win32') {
} }
var dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid; var dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid;
common.refreshTmpDir();
fs.mkdirSync(dirname); fs.mkdirSync(dirname);
process.chdir(dirname); process.chdir(dirname);
fs.rmdirSync(dirname); fs.rmdirSync(dirname);

1
test/parallel/test-cwd-enoent.js

@ -11,6 +11,7 @@ if (process.platform === 'sunos' || process.platform === 'win32') {
} }
var dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid; var dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid;
common.refreshTmpDir();
fs.mkdirSync(dirname); fs.mkdirSync(dirname);
process.chdir(dirname); process.chdir(dirname);
fs.rmdirSync(dirname); fs.rmdirSync(dirname);

1
test/parallel/test-file-write-stream.js

@ -5,6 +5,7 @@ var assert = require('assert');
var path = require('path'); var path = require('path');
var fs = require('fs'); var fs = require('fs');
var fn = path.join(common.tmpDir, 'write.txt'); var fn = path.join(common.tmpDir, 'write.txt');
common.refreshTmpDir();
var file = fs.createWriteStream(fn, { var file = fs.createWriteStream(fn, {
highWaterMark: 10 highWaterMark: 10
}); });

2
test/parallel/test-file-write-stream2.js

@ -39,7 +39,7 @@ function removeTestFile() {
} }
removeTestFile(); common.refreshTmpDir();
// drain at 0, return false at 10. // drain at 0, return false at 10.
file = fs.createWriteStream(filepath, { file = fs.createWriteStream(filepath, {

2
test/parallel/test-file-write-stream3.js

@ -39,7 +39,7 @@ function removeTestFile() {
} }
removeTestFile(); common.refreshTmpDir();
function run_test_1() { function run_test_1() {

1
test/parallel/test-fs-access.js

@ -21,6 +21,7 @@ var createFileWithPerms = function(file, mode) {
fs.chmodSync(file, mode); fs.chmodSync(file, mode);
}; };
common.refreshTmpDir();
createFileWithPerms(readOnlyFile, 0o444); createFileWithPerms(readOnlyFile, 0o444);
createFileWithPerms(readWriteFile, 0o666); createFileWithPerms(readWriteFile, 0o666);

2
test/parallel/test-fs-append-file-sync.js

@ -15,6 +15,8 @@ var data = '南越国是前203年至前111年存在于岭南地区的一个国
'历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' + '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' +
'它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n'; '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n';
common.refreshTmpDir();
// test that empty file will be created and have content added // test that empty file will be created and have content added
var filename = join(common.tmpDir, 'append-sync.txt'); var filename = join(common.tmpDir, 'append-sync.txt');

2
test/parallel/test-fs-append-file.js

@ -21,6 +21,8 @@ var s = '南越国是前203年至前111年存在于岭南地区的一个国家
var ncallbacks = 0; var ncallbacks = 0;
common.refreshTmpDir();
// test that empty file will be created and have content added // test that empty file will be created and have content added
fs.appendFile(filename, s, function(e) { fs.appendFile(filename, s, function(e) {
if (e) throw e; if (e) throw e;

4
test/parallel/test-fs-chmod.js

@ -111,9 +111,7 @@ fs.open(file2, 'a', function(err, fd) {
if (fs.lchmod) { if (fs.lchmod) {
var link = path.join(common.tmpDir, 'symbolic-link'); var link = path.join(common.tmpDir, 'symbolic-link');
try { common.refreshTmpDir();
fs.unlinkSync(link);
} catch (er) {}
fs.symlinkSync(file2, link); fs.symlinkSync(file2, link);
fs.lchmod(link, mode_async, function(err) { fs.lchmod(link, mode_async, function(err) {

7
test/parallel/test-fs-long-path.js

@ -11,12 +11,7 @@ var fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1);
var fileName = path.join(common.tmpDir, new Array(fileNameLen + 1).join('x')); var fileName = path.join(common.tmpDir, new Array(fileNameLen + 1).join('x'));
var fullPath = path.resolve(fileName); var fullPath = path.resolve(fileName);
try { common.refreshTmpDir();
fs.unlinkSync(fullPath);
}
catch (e) {
// Ignore.
}
console.log({ console.log({
filenameLength: fileName.length, filenameLength: fileName.length,

2
test/parallel/test-fs-mkdir.js

@ -10,6 +10,8 @@ function unlink(pathname) {
} }
} }
common.refreshTmpDir();
(function() { (function() {
var ncalls = 0; var ncalls = 0;
var pathname = common.tmpDir + '/test1'; var pathname = common.tmpDir + '/test1';

1
test/parallel/test-fs-read-stream-fd.js

@ -10,6 +10,7 @@ var input = 'hello world';
var output = ''; var output = '';
var fd, stream; var fd, stream;
common.refreshTmpDir();
fs.writeFileSync(file, input); fs.writeFileSync(file, input);
fd = fs.openSync(file, 'r'); fd = fs.openSync(file, 'r');

1
test/parallel/test-fs-readfile-pipe-large.js

@ -15,6 +15,7 @@ var fs = require('fs');
var filename = path.join(common.tmpDir, '/readfile_pipe_large_test.txt'); var filename = path.join(common.tmpDir, '/readfile_pipe_large_test.txt');
var dataExpected = new Array(1000000).join('a'); var dataExpected = new Array(1000000).join('a');
common.refreshTmpDir();
fs.writeFileSync(filename, dataExpected); fs.writeFileSync(filename, dataExpected);
if (process.argv[2] === 'child') { if (process.argv[2] === 'child') {

1
test/parallel/test-fs-readfilesync-pipe-large.js

@ -15,6 +15,7 @@ var fs = require('fs');
var filename = path.join(common.tmpDir, '/readfilesync_pipe_large_test.txt'); var filename = path.join(common.tmpDir, '/readfilesync_pipe_large_test.txt');
var dataExpected = new Array(1000000).join('a'); var dataExpected = new Array(1000000).join('a');
common.refreshTmpDir();
fs.writeFileSync(filename, dataExpected); fs.writeFileSync(filename, dataExpected);
if (process.argv[2] === 'child') { if (process.argv[2] === 'child') {

5
test/parallel/test-fs-realpath.js

@ -8,6 +8,8 @@ var async_completed = 0, async_expected = 0, unlink = [];
var isWindows = process.platform === 'win32'; var isWindows = process.platform === 'win32';
var skipSymlinks = false; var skipSymlinks = false;
common.refreshTmpDir();
var root = '/'; var root = '/';
if (isWindows) { if (isWindows) {
// something like "C:\\" // something like "C:\\"
@ -575,9 +577,6 @@ function runTest() {
var tmpDirs = ['cycles', 'cycles/folder']; var tmpDirs = ['cycles', 'cycles/folder'];
tmpDirs.forEach(function(t) { tmpDirs.forEach(function(t) {
t = tmp(t); t = tmp(t);
var s;
try { s = fs.statSync(t); } catch (ex) {}
if (s) return;
fs.mkdirSync(t, 0o700); fs.mkdirSync(t, 0o700);
}); });
fs.writeFileSync(tmp('cycles/root.js'), "console.error('roooot!');"); fs.writeFileSync(tmp('cycles/root.js'), "console.error('roooot!');");

6
test/parallel/test-fs-sir-writes-alot.js

@ -6,11 +6,7 @@ var join = require('path').join;
var filename = join(common.tmpDir, 'out.txt'); var filename = join(common.tmpDir, 'out.txt');
try { common.refreshTmpDir();
fs.unlinkSync(filename);
} catch (e) {
// might not exist, that's okay.
}
var fd = fs.openSync(filename, 'w'); var fd = fs.openSync(filename, 'w');

2
test/parallel/test-fs-stream-double-close.js

@ -3,6 +3,8 @@ var common = require('../common');
var assert = require('assert'); var assert = require('assert');
var fs = require('fs'); var fs = require('fs');
common.refreshTmpDir();
test1(fs.createReadStream(__filename)); test1(fs.createReadStream(__filename));
test2(fs.createReadStream(__filename)); test2(fs.createReadStream(__filename));
test3(fs.createReadStream(__filename)); test3(fs.createReadStream(__filename));

5
test/parallel/test-fs-symlink-dir-junction-relative.js

@ -13,10 +13,7 @@ var linkPath2 = path.join(common.tmpDir, 'junction2');
var linkTarget = path.join(common.fixturesDir); var linkTarget = path.join(common.fixturesDir);
var linkData = '../fixtures'; var linkData = '../fixtures';
// Prepare. common.refreshTmpDir();
try { fs.mkdirSync(common.tmpDir); } catch (e) {}
try { fs.unlinkSync(linkPath1); } catch (e) {}
try { fs.unlinkSync(linkPath2); } catch (e) {}
// Test fs.symlink() // Test fs.symlink()
fs.symlink(linkData, linkPath1, 'junction', function(err) { fs.symlink(linkData, linkPath1, 'junction', function(err) {

5
test/parallel/test-fs-symlink-dir-junction.js

@ -10,10 +10,7 @@ var expected_tests = 4;
var linkData = path.join(common.fixturesDir, 'cycles/'); var linkData = path.join(common.fixturesDir, 'cycles/');
var linkPath = path.join(common.tmpDir, 'cycles_link'); var linkPath = path.join(common.tmpDir, 'cycles_link');
// Delete previously created link common.refreshTmpDir();
try {
fs.unlinkSync(linkPath);
} catch (e) {}
console.log('linkData: ' + linkData); console.log('linkData: ' + linkData);
console.log('linkPath: ' + linkPath); console.log('linkPath: ' + linkPath);

12
test/parallel/test-fs-symlink.js

@ -9,17 +9,14 @@ var expected_tests = 2;
var is_windows = process.platform === 'win32'; var is_windows = process.platform === 'win32';
common.refreshTmpDir();
var runtest = function(skip_symlinks) { var runtest = function(skip_symlinks) {
if (!skip_symlinks) { if (!skip_symlinks) {
// test creating and reading symbolic link // test creating and reading symbolic link
var linkData = path.join(common.fixturesDir, '/cycles/root.js'); var linkData = path.join(common.fixturesDir, '/cycles/root.js');
var linkPath = path.join(common.tmpDir, 'symlink1.js'); var linkPath = path.join(common.tmpDir, 'symlink1.js');
// Delete previously created link
try {
fs.unlinkSync(linkPath);
} catch (e) {}
fs.symlink(linkData, linkPath, function(err) { fs.symlink(linkData, linkPath, function(err) {
if (err) throw err; if (err) throw err;
console.log('symlink done'); console.log('symlink done');
@ -36,11 +33,6 @@ var runtest = function(skip_symlinks) {
var srcPath = path.join(common.fixturesDir, 'cycles', 'root.js'); var srcPath = path.join(common.fixturesDir, 'cycles', 'root.js');
var dstPath = path.join(common.tmpDir, 'link1.js'); var dstPath = path.join(common.tmpDir, 'link1.js');
// Delete previously created link
try {
fs.unlinkSync(dstPath);
} catch (e) {}
fs.link(srcPath, dstPath, function(err) { fs.link(srcPath, dstPath, function(err) {
if (err) throw err; if (err) throw err;
console.log('hard link done'); console.log('hard link done');

2
test/parallel/test-fs-truncate-GH-6233.js

@ -5,6 +5,8 @@ var fs = require('fs');
var filename = common.tmpDir + '/truncate-file.txt'; var filename = common.tmpDir + '/truncate-file.txt';
common.refreshTmpDir();
// Synchronous test. // Synchronous test.
(function() { (function() {
fs.writeFileSync(filename, '0123456789'); fs.writeFileSync(filename, '0123456789');

3
test/parallel/test-fs-truncate-fd.js

@ -4,8 +4,7 @@ var assert = require('assert');
var path = require('path'); var path = require('path');
var fs = require('fs'); var fs = require('fs');
var tmp = common.tmpDir; var tmp = common.tmpDir;
if (!fs.existsSync(tmp)) common.refreshTmpDir();
fs.mkdirSync(tmp);
var filename = path.resolve(tmp, 'truncate-file.txt'); var filename = path.resolve(tmp, 'truncate-file.txt');
var success = 0; var success = 0;

2
test/parallel/test-fs-truncate.js

@ -8,6 +8,8 @@ var filename = path.resolve(tmp, 'truncate-file.txt');
var data = new Buffer(1024 * 16); var data = new Buffer(1024 * 16);
data.fill('x'); data.fill('x');
common.refreshTmpDir();
var stat; var stat;
// truncateSync // truncateSync

2
test/parallel/test-fs-write-buffer.js

@ -10,6 +10,8 @@ var path = require('path'),
writeCalled = 0; writeCalled = 0;
common.refreshTmpDir();
fs.open(filename, 'w', 0o644, function(err, fd) { fs.open(filename, 'w', 0o644, function(err, fd) {
openCalled++; openCalled++;
if (err) throw err; if (err) throw err;

2
test/parallel/test-fs-write-file-buffer.js

@ -25,6 +25,8 @@ var data = [
data = data.join('\n'); data = data.join('\n');
common.refreshTmpDir();
var buf = new Buffer(data, 'base64'); var buf = new Buffer(data, 'base64');
fs.writeFileSync(join(common.tmpDir, 'test.jpg'), buf); fs.writeFileSync(join(common.tmpDir, 'test.jpg'), buf);

20
test/parallel/test-fs-write-file-sync.js

@ -26,9 +26,10 @@ if (isWindows) {
mode = 0o755; mode = 0o755;
} }
common.refreshTmpDir();
// Test writeFileSync // Test writeFileSync
var file1 = path.join(common.tmpDir, 'testWriteFileSync.txt'); var file1 = path.join(common.tmpDir, 'testWriteFileSync.txt');
removeFile(file1);
fs.writeFileSync(file1, '123', {mode: mode}); fs.writeFileSync(file1, '123', {mode: mode});
@ -37,11 +38,8 @@ assert.equal('123', content);
assert.equal(mode, fs.statSync(file1).mode & 0o777); assert.equal(mode, fs.statSync(file1).mode & 0o777);
removeFile(file1);
// Test appendFileSync // Test appendFileSync
var file2 = path.join(common.tmpDir, 'testAppendFileSync.txt'); var file2 = path.join(common.tmpDir, 'testAppendFileSync.txt');
removeFile(file2);
fs.appendFileSync(file2, 'abc', {mode: mode}); fs.appendFileSync(file2, 'abc', {mode: mode});
@ -50,23 +48,9 @@ assert.equal('abc', content);
assert.equal(mode, fs.statSync(file2).mode & mode); assert.equal(mode, fs.statSync(file2).mode & mode);
removeFile(file2);
// Verify that all opened files were closed. // Verify that all opened files were closed.
assert.equal(0, openCount); assert.equal(0, openCount);
// Removes a file if it exists.
function removeFile(file) {
try {
if (isWindows)
fs.chmodSync(file, 0o666);
fs.unlinkSync(file);
} catch (err) {
if (err && err.code !== 'ENOENT')
throw err;
}
}
function openSync() { function openSync() {
openCount++; openCount++;
return fs._openSync.apply(fs, arguments); return fs._openSync.apply(fs, arguments);

2
test/parallel/test-fs-write-file.js

@ -4,6 +4,8 @@ var assert = require('assert');
var fs = require('fs'); var fs = require('fs');
var join = require('path').join; var join = require('path').join;
common.refreshTmpDir();
var filename = join(common.tmpDir, 'test.txt'); var filename = join(common.tmpDir, 'test.txt');
common.error('writing to ' + filename); common.error('writing to ' + filename);

2
test/parallel/test-fs-write-stream-change-open.js

@ -7,6 +7,8 @@ var path = require('path'),
var file = path.join(common.tmpDir, 'write.txt'); var file = path.join(common.tmpDir, 'write.txt');
common.refreshTmpDir();
var stream = fs.WriteStream(file), var stream = fs.WriteStream(file),
_fs_close = fs.close, _fs_close = fs.close,
_fs_open = fs.open; _fs_open = fs.open;

2
test/parallel/test-fs-write-stream-encoding.js

@ -10,6 +10,8 @@ const secondEncoding = 'binary';
const examplePath = path.join(common.fixturesDir, 'x.txt'); const examplePath = path.join(common.fixturesDir, 'x.txt');
const dummyPath = path.join(common.tmpDir, 'x.txt'); const dummyPath = path.join(common.tmpDir, 'x.txt');
common.refreshTmpDir();
const exampleReadStream = fs.createReadStream(examplePath, { const exampleReadStream = fs.createReadStream(examplePath, {
encoding: firstEncoding encoding: firstEncoding
}); });

2
test/parallel/test-fs-write-stream-end.js

@ -4,6 +4,8 @@ var assert = require('assert');
var path = require('path'); var path = require('path');
var fs = require('fs'); var fs = require('fs');
common.refreshTmpDir();
(function() { (function() {
var file = path.join(common.tmpDir, 'write-end-test0.txt'); var file = path.join(common.tmpDir, 'write-end-test0.txt');
var stream = fs.createWriteStream(file); var stream = fs.createWriteStream(file);

2
test/parallel/test-fs-write-stream-err.js

@ -3,6 +3,8 @@ var common = require('../common');
var assert = require('assert'); var assert = require('assert');
var fs = require('fs'); var fs = require('fs');
common.refreshTmpDir();
var stream = fs.createWriteStream(common.tmpDir + '/out', { var stream = fs.createWriteStream(common.tmpDir + '/out', {
highWaterMark: 10 highWaterMark: 10
}); });

2
test/parallel/test-fs-write-stream-throw-type-error.js

@ -6,6 +6,8 @@ const path = require('path');
const example = path.join(common.tmpDir, 'dummy'); const example = path.join(common.tmpDir, 'dummy');
common.refreshTmpDir();
assert.doesNotThrow(function() { assert.doesNotThrow(function() {
fs.createWriteStream(example, undefined); fs.createWriteStream(example, undefined);
}); });

2
test/parallel/test-fs-write-stream.js

@ -7,6 +7,8 @@ var path = require('path'),
var file = path.join(common.tmpDir, 'write.txt'); var file = path.join(common.tmpDir, 'write.txt');
common.refreshTmpDir();
(function() { (function() {
var stream = fs.WriteStream(file), var stream = fs.WriteStream(file),
_fs_close = fs.close; _fs_close = fs.close;

3
test/parallel/test-fs-write-string-coerce.js

@ -4,6 +4,9 @@ var assert = require('assert');
var path = require('path'); var path = require('path');
var Buffer = require('buffer').Buffer; var Buffer = require('buffer').Buffer;
var fs = require('fs'); var fs = require('fs');
common.refreshTmpDir();
var fn = path.join(common.tmpDir, 'write-string-coerce.txt'); var fn = path.join(common.tmpDir, 'write-string-coerce.txt');
var data = true; var data = true;
var expected = data + ''; var expected = data + '';

1
test/parallel/test-fs-write-sync.js

@ -5,6 +5,7 @@ var path = require('path');
var fs = require('fs'); var fs = require('fs');
var fn = path.join(common.tmpDir, 'write.txt'); var fn = path.join(common.tmpDir, 'write.txt');
common.refreshTmpDir();
var foo = 'foo'; var foo = 'foo';
var fd = fs.openSync(fn, 'w'); var fd = fs.openSync(fn, 'w');

2
test/parallel/test-fs-write.js

@ -10,6 +10,8 @@ var expected = 'ümlaut.';
var constants = require('constants'); var constants = require('constants');
var found, found2; var found, found2;
common.refreshTmpDir();
fs.open(fn, 'w', 0o644, function(err, fd) { fs.open(fn, 'w', 0o644, function(err, fd) {
if (err) throw err; if (err) throw err;
console.log('open done'); console.log('open done');

2
test/parallel/test-http-curl-chunk-problem.js

@ -30,6 +30,8 @@ function maybeMakeRequest() {
} }
common.refreshTmpDir();
var ddcmd = common.ddCommand(filename, 10240); var ddcmd = common.ddCommand(filename, 10240);
console.log('dd command: ', ddcmd); console.log('dd command: ', ddcmd);

2
test/parallel/test-http-get-pipeline-problem.js

@ -7,6 +7,8 @@ var assert = require('assert');
var http = require('http'); var http = require('http');
var fs = require('fs'); var fs = require('fs');
common.refreshTmpDir();
var image = fs.readFileSync(common.fixturesDir + '/person.jpg'); var image = fs.readFileSync(common.fixturesDir + '/person.jpg');
console.log('image.length = ' + image.length); console.log('image.length = ' + image.length);

2
test/parallel/test-http-pipe-fs.js

@ -5,6 +5,8 @@ var http = require('http');
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
common.refreshTmpDir();
var file = path.join(common.tmpDir, 'http-pipe-fs-test.txt'); var file = path.join(common.tmpDir, 'http-pipe-fs-test.txt');
var requests = 0; var requests = 0;

2
test/parallel/test-https-truncate.js

@ -11,8 +11,6 @@ var https = require('https');
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
var resultFile = path.resolve(common.tmpDir, 'result');
var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');

2
test/parallel/test-pipe-file-to-http.js

@ -6,6 +6,8 @@ var http = require('http');
var path = require('path'); var path = require('path');
var cp = require('child_process'); var cp = require('child_process');
common.refreshTmpDir();
var filename = path.join(common.tmpDir || '/tmp', 'big'); var filename = path.join(common.tmpDir || '/tmp', 'big');
var clientReqComplete = false; var clientReqComplete = false;
var count = 0; var count = 0;

2
test/parallel/test-repl-.save.load.js

@ -5,6 +5,8 @@ var join = require('path').join;
var fs = require('fs'); var fs = require('fs');
var common = require('../common'); var common = require('../common');
common.refreshTmpDir();
var repl = require('repl'); var repl = require('repl');
// A stream to push an array into a REPL // A stream to push an array into a REPL

2
test/parallel/test-zlib-from-gzip.js

@ -7,6 +7,8 @@ var assert = require('assert');
var zlib = require('zlib'); var zlib = require('zlib');
var path = require('path'); var path = require('path');
common.refreshTmpDir();
var gunzip = zlib.createGunzip(); var gunzip = zlib.createGunzip();
var fs = require('fs'); var fs = require('fs');

2
test/sequential/test-fs-watch-recursive.js

@ -15,6 +15,8 @@ if (process.platform === 'darwin') {
var relativePathOne = path.join('testsubdir', filenameOne); var relativePathOne = path.join('testsubdir', filenameOne);
var filepathOne = path.join(testsubdir, filenameOne); var filepathOne = path.join(testsubdir, filenameOne);
common.refreshTmpDir();
process.on('exit', function() { process.on('exit', function() {
assert.ok(watchSeenOne > 0); assert.ok(watchSeenOne > 0);
}); });

6
test/sequential/test-fs-watch.js

@ -32,11 +32,7 @@ process.on('exit', function() {
assert.ok(watchSeenThree > 0); assert.ok(watchSeenThree > 0);
}); });
// Clean up stale files (if any) from previous run. common.refreshTmpDir();
try { fs.unlinkSync(filepathOne); } catch (e) { }
try { fs.unlinkSync(filepathTwoAbs); } catch (e) { }
try { fs.unlinkSync(filepathThree); } catch (e) { }
try { fs.rmdirSync(testsubdir); } catch (e) { }
fs.writeFileSync(filepathOne, 'hello'); fs.writeFileSync(filepathOne, 'hello');

2
test/sequential/test-mkdir-rmdir.js

@ -4,6 +4,8 @@ var assert = require('assert');
var path = require('path'); var path = require('path');
var fs = require('fs'); var fs = require('fs');
common.refreshTmpDir();
var dirname = path.dirname(__filename); var dirname = path.dirname(__filename);
var d = path.join(common.tmpDir, 'dir'); var d = path.join(common.tmpDir, 'dir');

2
test/sequential/test-regress-GH-4027.js

@ -4,6 +4,8 @@ var assert = require('assert');
var path = require('path'); var path = require('path');
var fs = require('fs'); var fs = require('fs');
common.refreshTmpDir();
var filename = path.join(common.tmpDir, 'watched'); var filename = path.join(common.tmpDir, 'watched');
fs.writeFileSync(filename, 'quis custodiet ipsos custodes'); fs.writeFileSync(filename, 'quis custodiet ipsos custodes');
setTimeout(fs.unlinkSync, 100, filename); setTimeout(fs.unlinkSync, 100, filename);

2
test/sequential/test-stdout-to-file.js

@ -9,6 +9,8 @@ var scriptString = path.join(common.fixturesDir, 'print-chars.js');
var scriptBuffer = path.join(common.fixturesDir, 'print-chars-from-buffer.js'); var scriptBuffer = path.join(common.fixturesDir, 'print-chars-from-buffer.js');
var tmpFile = path.join(common.tmpDir, 'stdout.txt'); var tmpFile = path.join(common.tmpDir, 'stdout.txt');
common.refreshTmpDir();
function test(size, useBuffer, cb) { function test(size, useBuffer, cb) {
var cmd = '"' + process.argv[0] + '"' + var cmd = '"' + process.argv[0] + '"' +
' ' + ' ' +

Loading…
Cancel
Save