fix unit testing with platform deps requirement

This commit is contained in:
Pierre Tachoire
2025-07-01 16:21:47 -07:00
parent 3c0143af92
commit a3c14748d3
2 changed files with 11 additions and 3 deletions

View File

@@ -274,12 +274,20 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
} }
pub fn pumpMessageLoop(self: *const Self) bool { pub fn pumpMessageLoop(self: *const Self) bool {
if (self.platform == null) return false; if (self.platform == null) {
// In test mode only, platform can be null.
if (builtin.is_test) return false;
@panic("platform is null");
}
return self.platform.?.inner.pumpMessageLoop(self.isolate, false); return self.platform.?.inner.pumpMessageLoop(self.isolate, false);
} }
pub fn runIdleTasks(self: *const Self) void { pub fn runIdleTasks(self: *const Self) void {
if (self.platform == null) return; if (self.platform == null) {
// In test mode only, platform can be null.
if (builtin.is_test) return;
@panic("platform is null");
}
return self.platform.?.inner.runIdleTasks(self.isolate, 1); return self.platform.?.inner.runIdleTasks(self.isolate, 1);
} }

View File

@@ -42,7 +42,7 @@ pub fn Runner(comptime State: type, comptime Global: type, comptime types: anyty
const self = try allocator.create(Self); const self = try allocator.create(Self);
errdefer allocator.destroy(self); errdefer allocator.destroy(self);
self.env = try Env.init(allocator, .{}); self.env = try Env.init(allocator, null, .{});
errdefer self.env.deinit(); errdefer self.env.deinit();
self.executor = try self.env.newExecutionWorld(); self.executor = try self.env.newExecutionWorld();