test: fix flaky parallel/test-fs-write-file-typedarrays

Using the same filename for different async tests could lead
to race conditions.

Example failure: https://travis-ci.com/nodejs/node/jobs/143351655

Refs: https://github.com/nodejs/node/pull/22150

PR-URL: https://github.com/nodejs/node/pull/22659
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Anna Henningsen 2018-09-02 17:51:23 +02:00
parent 64cf96d684
commit ba43bce9e2
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -32,10 +32,11 @@ for (const expectView of common.getArrayBufferViews(inputBuffer)) {
for (const expectView of common.getArrayBufferViews(inputBuffer)) {
console.log('Async test for ', expectView[Symbol.toStringTag]);
fs.writeFile(filename, expectView, common.mustCall((e) => {
const file = `${filename}-${expectView[Symbol.toStringTag]}`;
fs.writeFile(file, expectView, common.mustCall((e) => {
assert.ifError(e);
fs.readFile(filename, 'utf8', common.mustCall((err, data) => {
fs.readFile(file, 'utf8', common.mustCall((err, data) => {
assert.ifError(err);
assert.strictEqual(data, inputBuffer.toString('utf8'));
}));