Skip to content

Commit 02b3a5b

Browse files
TrottFishrock123
authored andcommittedJan 6, 2016
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: #4476 (comment) PR-URL: #4490 Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent ab3e5c1 commit 02b3a5b

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed
 

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

+4-14
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)