From 94e36f1f3160fc318114496288aa11b7a4c6dd3a Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 25 Jan 2018 23:01:01 +0800 Subject: [PATCH] test: fix flaky test-fs-write PR-URL: https://github.com/nodejs/node/pull/18374 Reviewed-By: Richard Lau Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Colin Ihrig --- test/parallel/test-fs-write.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-fs-write.js b/test/parallel/test-fs-write.js index 7e8d6f8b53963a..911d6e696bd3f5 100644 --- a/test/parallel/test-fs-write.js +++ b/test/parallel/test-fs-write.js @@ -34,6 +34,8 @@ const constants = fs.constants; /* eslint-disable no-undef */ common.allowGlobals(externalizeString, isOneByteString, x); +common.refreshTmpDir(); + { const expected = 'ümlaut eins'; // Must be a unique string. externalizeString(expected); @@ -74,8 +76,6 @@ common.allowGlobals(externalizeString, isOneByteString, x); assert.strictEqual(expected, fs.readFileSync(fn, 'utf8')); } -common.refreshTmpDir(); - fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) { assert.ifError(err); @@ -91,10 +91,10 @@ fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) { const written = common.mustCall(function(err, written) { assert.ifError(err); assert.strictEqual(0, written); + fs.write(fd, expected, 0, 'utf8', done); }); fs.write(fd, '', 0, 'utf8', written); - fs.write(fd, expected, 0, 'utf8', done); })); const args = constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC; @@ -113,10 +113,10 @@ fs.open(fn2, args, 0o644, common.mustCall((err, fd) => { const written = common.mustCall(function(err, written) { assert.ifError(err); assert.strictEqual(0, written); + fs.write(fd, expected, 0, 'utf8', done); }); fs.write(fd, '', 0, 'utf8', written); - fs.write(fd, expected, 0, 'utf8', done); })); fs.open(fn3, 'w', 0o644, common.mustCall(function(err, fd) {