Skip to content

Commit

Permalink
test: fix flaky interval test
Browse files Browse the repository at this point in the history
PR-URL: #18140
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
apapirovski committed Jan 14, 2018
1 parent 75032c9 commit 8d04323
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ const Timer = process.binding('timer_wrap').Timer;
const assert = require('assert');

let cntr = 0;
let first, second;
let first;
const t = setInterval(() => {
common.busyLoop(50);
cntr++;
if (cntr === 1) {
first = Timer.now();
common.busyLoop(100);
} else if (cntr === 2) {
second = Timer.now();
assert(Math.abs(second - first - 100) < 10);
assert(Timer.now() - first < 120);
clearInterval(t);
}
}, 100);

0 comments on commit 8d04323

Please sign in to comment.