0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-fs-existssync-false.js
Ujjwal Sharma 580ad0157a
test: name test files appropriately
Rename the tests appropriately alongside mentioning the subsystem.
Also, make a few basic changes to make sure the test conforms
to the standard test structure.

This renames:
- test-regress-GH-1531
- test-regress-GH-2245
- test-regress-GH-3238
- test-regress-GH-3542
- test-regress-GH-3739
- test-regress-GH-4256

PR-URL: https://github.com/nodejs/node/pull/19212
Refs: https://github.com/nodejs/node/issues/19105
Refs: https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md#test-structure
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-11 04:17:42 +01:00

37 lines
842 B
JavaScript

'use strict';
const common = require('../common');
const tmpdir = require('../common/tmpdir');
// This test ensures that fs.existsSync doesn't incorrectly return false.
// (especially on Windows)
// https://github.com/nodejs/node-v0.x-archive/issues/3739
const assert = require('assert');
const fs = require('fs');
const path = require('path');
let dir = path.resolve(tmpdir.path);
// Make sure that the tmp directory is clean
tmpdir.refresh();
// Make a long path.
for (let 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.ifError(err);
});