test: refactor test-fs-readfile-unlink · nodejs/node@2babae4

@@ -3,16 +3,11 @@ const common = require('../common');

33

const assert = require('assert');

44

const fs = require('fs');

55

const 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+88

const 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();

16111712

fs.writeFileSync(fileName, buf);

1813

@@ -21,6 +16,7 @@ fs.readFile(fileName, function(err, data) {

2116

assert.strictEqual(data.length, buf.length);

2217

assert.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.

2421

fs.unlinkSync(fileName);

25-

fs.rmdirSync(dirName);

2622

});