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: #4476 (comment)
PR-URL: #4490
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
Trott authored and Myles Borins committed Jan 19, 2016
1 parent 610727d commit 7ca3c6c
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 7ca3c6c

Please sign in to comment.