Skip to content

Commit 104fde8

Browse files
committed
test: refactor test-fs-empty-readStream
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)
1 parent bfa925f commit 104fde8

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

test/parallel/test-fs-empty-readStream.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@ fs.open(emptyFile, 'r', function(error, fd) {
1515
throw new Error('data event should not emit');
1616
});
1717

18-
var readEmit = false;
19-
read.once('end', function() {
20-
readEmit = true;
21-
console.error('end event 1');
22-
});
23-
24-
setTimeout(function() {
25-
assert.equal(readEmit, true);
26-
}, common.platformTimeout(50));
18+
read.once('end', common.mustCall(function endEvent1() {}));
2719
});
2820

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

39-
var readEmit = false;
40-
read.once('end', function() {
41-
readEmit = true;
42-
console.error('end event 2');
31+
read.once('end', function endEvent2() {
32+
throw new Error('end event should not emit');
4333
});
4434

4535
setTimeout(function() {
46-
assert.equal(readEmit, false);
36+
assert.equal(read.isPaused(), true);
4737
}, common.platformTimeout(50));
4838
});

0 commit comments

Comments
 (0)