Skip to content

Commit

Permalink
test: fix flaky test-fs-write
Browse files Browse the repository at this point in the history
PR-URL: #18374
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
joyeecheung committed Jan 29, 2018
1 parent eb34278 commit 94e36f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/parallel/test-fs-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit 94e36f1

Please sign in to comment.