test: refactor test-fs-readfile-unlink · nodejs/node@2babae4
@@ -3,16 +3,11 @@ const common = require('../common');
33const assert = require('assert');
44const fs = require('fs');
55const path = require('path');
6-const dirName = path.resolve(common.fixturesDir, 'test-readfile-unlink');
7-const fileName = path.resolve(dirName, 'test.bin');
6+const fileName = path.resolve(common.tmpDir, 'test.bin');
7+88const buf = Buffer.alloc(512 * 1024, 42);
9910-try {
11-fs.mkdirSync(dirName);
12-} catch (e) {
13-// Ignore if the directory already exists.
14-if (e.code !== 'EEXIST') throw e;
15-}
10+common.refreshTmpDir();
16111712fs.writeFileSync(fileName, buf);
1813@@ -21,6 +16,7 @@ fs.readFile(fileName, function(err, data) {
2116assert.strictEqual(data.length, buf.length);
2217assert.strictEqual(buf[0], 42);
231819+// Unlink should not throw. This is part of the test. It used to throw on
20+// Windows due to a bug.
2421fs.unlinkSync(fileName);
25-fs.rmdirSync(dirName);
2622});