Skip to content

Commit 54afb19

Browse files
committed
Make the timeout test more resilient
Since we don't keep timers sorted by deadline but by insertion order, the test is flaky in slow environments (GHA seemingly). Increase the timeouts to give it a bigger chance of success. ASan / UBSan builds are notoriously slow, so skip the test in those.
1 parent 194c45c commit 54afb19

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ add_link_options(
128128
)
129129
elseif(CONFIG_UBSAN)
130130
message(STATUS "Building with UBSan")
131+
add_compile_definitions(
132+
__UBSAN__=1
133+
)
131134
add_compile_options(
132135
-fsanitize=undefined
133136
-fno-sanitize-recover=all

qjs.c

+3
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ static const JSCFunctionListEntry navigator_obj[] = {
140140
static const JSCFunctionListEntry global_obj[] = {
141141
JS_CFUNC_DEF("gc", 0, js_gc),
142142
JS_OBJECT_DEF("navigator", navigator_obj, countof(navigator_obj), JS_PROP_C_W_E),
143+
#if defined(__ASAN__) || defined(__UBSAN__)
144+
JS_PROP_INT32_DEF("__running_with_sanitizer__", 1, JS_PROP_C_W_E ),
145+
#endif
143146
};
144147

145148
/* also used to initialize the worker context */

tests/test_std.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,13 @@ function test_timeout()
277277

278278
function test_timeout_order()
279279
{
280+
if (globalThis.__running_with_sanitizer__) return;
281+
280282
var s = "";
281-
os.setTimeout(a, 1);
282-
os.setTimeout(b, 2);
283-
os.setTimeout(d, 5);
284-
function a() { s += "a"; os.setTimeout(c, 0); }
283+
os.setTimeout(a, 100);
284+
os.setTimeout(b, 200);
285+
os.setTimeout(d, 500);
286+
function a() { s += "a"; os.setTimeout(c, 200); }
285287
function b() { s += "b"; }
286288
function c() { s += "c"; }
287289
function d() { assert(s === "abc"); } // not "acb"

0 commit comments

Comments
 (0)