Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions test/parallel/test-fs-readfile-unlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,15 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
require('../common');
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const fixtures = require('../common/fixtures');

const dirName = fixtures.path('test-readfile-unlink');
const fileName = path.resolve(dirName, 'test.bin');
const fileName = path.resolve(common.tmpDir, 'test.bin');
const buf = Buffer.alloc(512 * 1024, 42);

try {
fs.mkdirSync(dirName);
} catch (e) {
// Ignore if the directory already exists.
if (e.code !== 'EEXIST') throw e;
}
common.refreshTmpDir();

fs.writeFileSync(fileName, buf);

Expand All @@ -44,6 +37,7 @@ fs.readFile(fileName, function(err, data) {
assert.strictEqual(data.length, buf.length);
assert.strictEqual(buf[0], 42);

// Unlink should not throw. This is part of the test. It used to throw on
// Windows due to a bug.
fs.unlinkSync(fileName);
fs.rmdirSync(dirName);
});