summaryrefslogtreecommitdiff
path: root/test/parallel/test-stream2-readable-empty-buffer-no-eof.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2016-01-02 21:39:55 -0800
committerJames M Snell <jasnell@gmail.com>2016-01-04 09:18:32 -0800
commit68bafb8baf6548f60a3fa5b27e8ff4bb50952d7c (patch)
tree5c383b1cb347ef9ef3bccdad29870364980d4b80 /test/parallel/test-stream2-readable-empty-buffer-no-eof.js
parent6ea8b0198726c946ab94c5735f2cfad9dae11bed (diff)
downloadandroid-node-v8-68bafb8baf6548f60a3fa5b27e8ff4bb50952d7c.tar.gz
android-node-v8-68bafb8baf6548f60a3fa5b27e8ff4bb50952d7c.tar.bz2
android-node-v8-68bafb8baf6548f60a3fa5b27e8ff4bb50952d7c.zip
test: fix flaky streams test
Use common.platformTimeout() to fix flaky test-stream2-readable-empty-buffer-no-eofi on Raspberry Pis. Fixes: https://github.com/nodejs/node/issues/4493 PR-URL: https://github.com/nodejs/node/pull/4516 Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell<jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-stream2-readable-empty-buffer-no-eof.js')
-rw-r--r--test/parallel/test-stream2-readable-empty-buffer-no-eof.js24
1 files changed, 12 insertions, 12 deletions
diff --git a/test/parallel/test-stream2-readable-empty-buffer-no-eof.js b/test/parallel/test-stream2-readable-empty-buffer-no-eof.js
index 2ebb1a696f..18012df3a4 100644
--- a/test/parallel/test-stream2-readable-empty-buffer-no-eof.js
+++ b/test/parallel/test-stream2-readable-empty-buffer-no-eof.js
@@ -1,14 +1,14 @@
'use strict';
-require('../common');
-var assert = require('assert');
+const common = require('../common');
+const assert = require('assert');
-var Readable = require('stream').Readable;
+const Readable = require('stream').Readable;
test1();
test2();
function test1() {
- var r = new Readable();
+ const r = new Readable();
// should not end when we get a Buffer(0) or '' as the _read result
// that just means that there is *temporarily* no data, but to go
@@ -20,9 +20,9 @@ function test1() {
// r.read(0) again later, otherwise there is no more work being done
// and the process just exits.
- var buf = new Buffer(5);
- buf.fill('x');
- var reads = 5;
+ const buf = Buffer(5).fill('x');
+ let reads = 5;
+ const timeout = common.platformTimeout(50);
r._read = function(n) {
switch (reads--) {
case 0:
@@ -30,15 +30,15 @@ function test1() {
case 1:
return r.push(buf);
case 2:
- setTimeout(r.read.bind(r, 0), 50);
+ setTimeout(r.read.bind(r, 0), timeout);
return r.push(new Buffer(0)); // Not-EOF!
case 3:
- setTimeout(r.read.bind(r, 0), 50);
+ setTimeout(r.read.bind(r, 0), timeout);
return process.nextTick(function() {
return r.push(new Buffer(0));
});
case 4:
- setTimeout(r.read.bind(r, 0), 50);
+ setTimeout(r.read.bind(r, 0), timeout);
return setTimeout(function() {
return r.push(new Buffer(0));
});
@@ -51,9 +51,9 @@ function test1() {
}
};
- var results = [];
+ const results = [];
function flow() {
- var chunk;
+ let chunk;
while (null !== (chunk = r.read()))
results.push(chunk + '');
}