mirror of https://github.com/nodejs/node.git
test: use tmpDir instead of fixturesDir
This test was using fixturesDir to create temp files to test. This patch replaces that with tmpDir and uses `assert` module to test. Also, this test has been moved to `parallel`, from `sequential` mode. PR-URL: https://github.com/nodejs/node/pull/2583 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com>pull/2587/head
parent
de88255b0f
commit
b11e256574
|
@ -0,0 +1,31 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
var dir = path.resolve(common.tmpDir);
|
||||||
|
|
||||||
|
// Make sure that the tmp directory is clean
|
||||||
|
common.refreshTmpDir();
|
||||||
|
|
||||||
|
// Make a long path.
|
||||||
|
for (var i = 0; i < 50; i++) {
|
||||||
|
dir = dir + '/1234567890';
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(dir, '0777');
|
||||||
|
} catch (e) {
|
||||||
|
if (e.code !== 'EEXIST') {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test if file exists synchronously
|
||||||
|
assert(common.fileExists(dir), 'Directory is not accessible');
|
||||||
|
|
||||||
|
// Test if file exists asynchronously
|
||||||
|
fs.access(dir, function(err) {
|
||||||
|
assert(!err, 'Directory is not accessible');
|
||||||
|
});
|
|
@ -1,46 +0,0 @@
|
||||||
'use strict';
|
|
||||||
var common = require('../common'),
|
|
||||||
assert = require('assert'),
|
|
||||||
fs = require('fs'),
|
|
||||||
path = require('path');
|
|
||||||
|
|
||||||
var dir = path.resolve(common.fixturesDir),
|
|
||||||
dirs = [];
|
|
||||||
|
|
||||||
// Make a long path.
|
|
||||||
for (var i = 0; i < 50; i++) {
|
|
||||||
dir = dir + '/123456790';
|
|
||||||
try {
|
|
||||||
fs.mkdirSync(dir, '0777');
|
|
||||||
} catch (e) {
|
|
||||||
if (e.code == 'EEXIST') {
|
|
||||||
// Ignore;
|
|
||||||
} else {
|
|
||||||
cleanup();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dirs.push(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test existsSync
|
|
||||||
var r = common.fileExists(dir);
|
|
||||||
if (r !== true) {
|
|
||||||
cleanup();
|
|
||||||
throw new Error('fs.accessSync returned false');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Text exists
|
|
||||||
fs.access(dir, function(err) {
|
|
||||||
cleanup();
|
|
||||||
if (err) {
|
|
||||||
throw new Error('fs.access reported false');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Remove all created directories
|
|
||||||
function cleanup() {
|
|
||||||
for (var i = dirs.length - 1; i >= 0; i--) {
|
|
||||||
fs.rmdirSync(dirs[i]);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue