dev: speedup unit tests

Directly improve a couple slow tests (crash_handler actually generating crash
dumps on some systems, e.g. mine). The runWebApiTest prefers to poll for work
when possible rather than a blind sleep -> check loop. (e.g. if we have
websocket connections, prefer an http tick).

For me, it's 22s -> 17s.
This commit is contained in:
Karl Seguin committed 2026-09-18 15:17:39 +08:00
1 parent e3aa36f83a
commit e2299e2c05
4 files changed
+24 -10

No files matched your search

+9 -2
View File
@@ -465,7 +465,7 @@ fn runWebApiTest(test_file: [:0]const u8, timeout_ms: u32) !void {
return;
}
const sleep_ms: usize = switch (try runner.tickForFrame(page.frame_id, 20, .{ .until = .done })) {
.done => 20,
.done => @min(test_session.browser.msToNextTask() orelse 20, 20), // could be at BLOCKING_NESTING, so wait a bit more
.ok => |next_ms| @min(next_ms, 20),
};
@@ -477,7 +477,14 @@ fn runWebApiTest(test_file: [:0]const u8, timeout_ms: u32) !void {
return error.TestTimedOut;
}
wait_ms -= @intCast(ms_elapsed);
lp.io.sleep(.fromMilliseconds(@intCast(sleep_ms)), .awake) catch {};
// WebSocket connection doesn't count as pending work, but we much prefer
// waiting on on activity than a blind sleep.
const http_client = &test_session.browser.http_client;
const waited = http_client.activity().ws_conns > 0 and try http_client.tick(@intCast(sleep_ms));
if (waited == false) {
lp.io.sleep(.fromMilliseconds(@intCast(sleep_ms)), .awake) catch {};
}
}
}