diff --git a/test/parallel/test-fs-readfile-unlink.js b/test/parallel/test-fs-readfile-unlink.js index 5b1cbd14f9c4a4..203ea681e5a079 100644 --- a/test/parallel/test-fs-readfile-unlink.js +++ b/test/parallel/test-fs-readfile-unlink.js @@ -3,16 +3,11 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); const path = require('path'); -const dirName = path.resolve(common.fixturesDir, '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); @@ -21,6 +16,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); });