diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2018-02-04 16:49:00 -0500 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2018-02-08 15:33:02 -0500 |
commit | 6963a93d0ec7b0020f243f2d49eba889a869cbed (patch) | |
tree | 749691df5f907d1928ac1d8c92d8bc4b577405eb /test/sequential | |
parent | ef78a1e584593438b1447033c1738a5f1efe638a (diff) | |
download | android-node-v8-6963a93d0ec7b0020f243f2d49eba889a869cbed.tar.gz android-node-v8-6963a93d0ec7b0020f243f2d49eba889a869cbed.tar.bz2 android-node-v8-6963a93d0ec7b0020f243f2d49eba889a869cbed.zip |
test: fix flaky timers-block-eventloop test
Due to extensive reliance on timings and the fs module, this test
is currently inherently flaky. Refactor it to simply use setImmediate
and only one busy loop.
PR-URL: https://github.com/nodejs/node/pull/18567
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/sequential')
-rw-r--r-- | test/sequential/test-timers-block-eventloop.js | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/test/sequential/test-timers-block-eventloop.js b/test/sequential/test-timers-block-eventloop.js index f6426e454e..811216fcb2 100644 --- a/test/sequential/test-timers-block-eventloop.js +++ b/test/sequential/test-timers-block-eventloop.js @@ -1,24 +1,18 @@ 'use strict'; const common = require('../common'); -const fs = require('fs'); -const platformTimeout = common.platformTimeout; +const assert = require('assert'); +let called = false; const t1 = setInterval(() => { - common.busyLoop(platformTimeout(12)); -}, platformTimeout(10)); - -const t2 = setInterval(() => { - common.busyLoop(platformTimeout(15)); -}, platformTimeout(10)); - -const t3 = - setTimeout(common.mustNotCall('eventloop blocked!'), platformTimeout(200)); - -setTimeout(function() { - fs.stat('/dev/nonexistent', () => { + assert(!called); + called = true; + setImmediate(common.mustCall(() => { clearInterval(t1); clearInterval(t2); - clearTimeout(t3); - }); -}, platformTimeout(50)); + })); +}, 10); + +const t2 = setInterval(() => { + common.busyLoop(20); +}, 10); |