Skip to content

Commit a3c1474

Browse files
committed
fix unit testing with platform deps requirement
1 parent 3c0143a commit a3c1474

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/runtime/js.zig

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,20 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
274274
}
275275

276276
pub fn pumpMessageLoop(self: *const Self) bool {
277-
if (self.platform == null) return false;
277+
if (self.platform == null) {
278+
// In test mode only, platform can be null.
279+
if (builtin.is_test) return false;
280+
@panic("platform is null");
281+
}
278282
return self.platform.?.inner.pumpMessageLoop(self.isolate, false);
279283
}
280284

281285
pub fn runIdleTasks(self: *const Self) void {
282-
if (self.platform == null) return;
286+
if (self.platform == null) {
287+
// In test mode only, platform can be null.
288+
if (builtin.is_test) return;
289+
@panic("platform is null");
290+
}
283291
return self.platform.?.inner.runIdleTasks(self.isolate, 1);
284292
}
285293

src/runtime/testing.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn Runner(comptime State: type, comptime Global: type, comptime types: anyty
4242
const self = try allocator.create(Self);
4343
errdefer allocator.destroy(self);
4444

45-
self.env = try Env.init(allocator, .{});
45+
self.env = try Env.init(allocator, null, .{});
4646
errdefer self.env.deinit();
4747

4848
self.executor = try self.env.newExecutionWorld();

0 commit comments

Comments
 (0)