Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b8f097e

Browse filesBrowse files
TrottMyles Borins
authored andcommitted
test: fix flaky streams test
Use common.platformTimeout() to fix flaky test-stream2-readable-empty-buffer-no-eofi on Raspberry Pis. Fixes: #4493 PR-URL: #4516 Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell<jasnell@gmail.com>
1 parent c24fa14 commit b8f097e
Copy full SHA for b8f097e

File tree

Expand file treeCollapse file tree

1 file changed

+12
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-12
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-stream2-readable-empty-buffer-no-eof.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream2-readable-empty-buffer-no-eof.js
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use strict';
2-
require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
3+
const assert = require('assert');
44

5-
var Readable = require('stream').Readable;
5+
const Readable = require('stream').Readable;
66

77
test1();
88
test2();
99

1010
function test1() {
11-
var r = new Readable();
11+
const r = new Readable();
1212

1313
// should not end when we get a Buffer(0) or '' as the _read result
1414
// that just means that there is *temporarily* no data, but to go
@@ -20,25 +20,25 @@ function test1() {
2020
// r.read(0) again later, otherwise there is no more work being done
2121
// and the process just exits.
2222

23-
var buf = new Buffer(5);
24-
buf.fill('x');
25-
var reads = 5;
23+
const buf = Buffer(5).fill('x');
24+
let reads = 5;
25+
const timeout = common.platformTimeout(50);
2626
r._read = function(n) {
2727
switch (reads--) {
2828
case 0:
2929
return r.push(null); // EOF
3030
case 1:
3131
return r.push(buf);
3232
case 2:
33-
setTimeout(r.read.bind(r, 0), 50);
33+
setTimeout(r.read.bind(r, 0), timeout);
3434
return r.push(new Buffer(0)); // Not-EOF!
3535
case 3:
36-
setTimeout(r.read.bind(r, 0), 50);
36+
setTimeout(r.read.bind(r, 0), timeout);
3737
return process.nextTick(function() {
3838
return r.push(new Buffer(0));
3939
});
4040
case 4:
41-
setTimeout(r.read.bind(r, 0), 50);
41+
setTimeout(r.read.bind(r, 0), timeout);
4242
return setTimeout(function() {
4343
return r.push(new Buffer(0));
4444
});
@@ -51,9 +51,9 @@ function test1() {
5151
}
5252
};
5353

54-
var results = [];
54+
const results = [];
5555
function flow() {
56-
var chunk;
56+
let chunk;
5757
while (null !== (chunk = r.read()))
5858
results.push(chunk + '');
5959
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.