mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-10-09 04:42:30 -04:00
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:
4 files changed
+24
-10
No files matched your search
+9
-2
@@ -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 {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user