Make the App own the Platform

Removes optional platform, which only existed for tests.

There is now a global `@import("testing.zig").test_app` available. This is setup
when the test runner starts, and cleaned up at the end of tests. Individual
tests don't have to worry about creating app, which I assume was the reason I
Platform optional, since that woul dhave been something else that needed to be
setup.
This commit is contained in:
Karl Seguin
2025-08-22 15:48:20 +08:00
parent 67b479b5c8
commit 687f09d952
10 changed files with 63 additions and 74 deletions

View File

@@ -71,7 +71,6 @@ const TestCDP = main.CDPT(struct {
});
const TestContext = struct {
app: *App,
client: ?Client = null,
cdp_: ?TestCDP = null,
arena: ArenaAllocator,
@@ -80,7 +79,6 @@ const TestContext = struct {
if (self.cdp_) |*c| {
c.deinit();
}
self.app.deinit();
self.arena.deinit();
}
@@ -89,7 +87,7 @@ const TestContext = struct {
self.client = Client.init(self.arena.allocator());
// Don't use the arena here. We want to detect leaks in CDP.
// The arena is only for test-specific stuff
self.cdp_ = TestCDP.init(self.app, &self.client.?) catch unreachable;
self.cdp_ = TestCDP.init(base.test_app, &self.client.?) catch unreachable;
}
return &self.cdp_.?;
}
@@ -221,7 +219,6 @@ const TestContext = struct {
pub fn context() TestContext {
return .{
.app = App.init(std.testing.allocator, .{ .run_mode = .serve }) catch unreachable,
.arena = ArenaAllocator.init(std.testing.allocator),
};
}