mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
test: deflake long timer WPTs
type-long-settimeout.any.js and type-long-setinterval.any.js arm setTimeout(assert_unreached, 100) as a guard. Under load it can fire after done(), and the resulting uncaught exception can reach the WPT runner before the completion message, failing the spec. Use a script modifier to clear the guard timer from a completion callback, for these two fixtures only. The guard still fails the test when done() is never called. Signed-off-by: marcopiraccini <marco.piraccini@gmail.com> PR-URL: https://github.com/nodejs/node/pull/63106 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
1 parent
ccafb30376
commit
009984dfec
1 file changed
+15
@@ -1,7 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const { basename } = require('path');
|
||||
const { WPTRunner } = require('../common/wpt');
|
||||
|
||||
const runner = new WPTRunner('html/webappapis/timers', { concurrency: 1 });
|
||||
|
||||
runner.setScriptModifier((script) => {
|
||||
if (!['type-long-settimeout.any.js', 'type-long-setinterval.any.js']
|
||||
.includes(basename(script.filename))) return;
|
||||
|
||||
// Cancel the failure timer when the test completes so it cannot throw
|
||||
// while the runner is still processing the completion message.
|
||||
const failureTimer = 'setTimeout(assert_unreached, 100);';
|
||||
assert(script.code.includes(failureTimer), `Unexpected contents of ${script.filename}`);
|
||||
script.code = script.code.replace(failureTimer,
|
||||
'const failureTimer = setTimeout(assert_unreached, 100);\n' +
|
||||
'add_completion_callback(() => clearTimeout(failureTimer));');
|
||||
});
|
||||
|
||||
runner.runJsTests();
|
||||
Reference in new issue
Block a user