Skip to content

Commit

Permalink
test: refactor test-fs-empty-readStream
Browse files Browse the repository at this point in the history
Refactor test to remove unnecessary booleans and one unnecesary timer.
Instead, throw Error objects where appropriate and rely on
common.mustCall().

The timer seemed to be the source of an issue when parallelizing tests.
Ref: nodejs#4476 (comment)
  • Loading branch information
Trott committed Dec 30, 2015
1 parent bfa925f commit 104fde8
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions test/parallel/test-fs-empty-readStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ fs.open(emptyFile, 'r', function(error, fd) {
throw new Error('data event should not emit');
});

var readEmit = false;
read.once('end', function() {
readEmit = true;
console.error('end event 1');
});

setTimeout(function() {
assert.equal(readEmit, true);
}, common.platformTimeout(50));
read.once('end', common.mustCall(function endEvent1() {}));
});

fs.open(emptyFile, 'r', function(error, fd) {
Expand All @@ -36,13 +28,11 @@ fs.open(emptyFile, 'r', function(error, fd) {
throw new Error('data event should not emit');
});

var readEmit = false;
read.once('end', function() {
readEmit = true;
console.error('end event 2');
read.once('end', function endEvent2() {
throw new Error('end event should not emit');
});

setTimeout(function() {
assert.equal(readEmit, false);
assert.equal(read.isPaused(), true);
}, common.platformTimeout(50));
});

0 comments on commit 104fde8

Please sign in to comment.