Skip to content

Commit fa2cd9d

Browse files
committed
Ability to start/stop CDP server.
Exists for cleaning up after tests.
1 parent 687f09d commit fa2cd9d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main.zig

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ const Allocator = std.mem.Allocator;
2222

2323
const log = @import("log.zig");
2424
const App = @import("app.zig").App;
25-
const Server = @import("server.zig").Server;
2625
const Http = @import("http/Http.zig");
27-
const Platform = @import("runtime/js.zig").Platform;
26+
const Server = @import("server.zig").Server;
2827
const Browser = @import("browser/browser.zig").Browser;
2928

3029
const build_config = @import("build_config");
@@ -717,6 +716,7 @@ test {
717716
std.testing.refAllDecls(@This());
718717
}
719718

719+
var test_cdp_server: ?Server = null;
720720
test "tests:beforeAll" {
721721
log.opts.level = .err;
722722
log.opts.format = .logfmt;
@@ -742,6 +742,9 @@ test "tests:beforeAll" {
742742
}
743743

744744
test "tests:afterAll" {
745+
if (test_cdp_server) |*server| {
746+
server.deinit();
747+
}
745748
testing.shutdown();
746749
}
747750

@@ -796,11 +799,13 @@ fn serveHTTP(wg: *std.Thread.WaitGroup) !void {
796799

797800
fn serveCDP(wg: *std.Thread.WaitGroup) !void {
798801
const address = try std.net.Address.parseIp("127.0.0.1", 9583);
802+
test_cdp_server = try Server.init(testing.test_app, address);
799803

800804
var server = try Server.init(testing.test_app, address);
801805
defer server.deinit();
802806
wg.finish();
803-
server.run(address, 5) catch |err| {
807+
808+
test_cdp_server.?.run(address, 5) catch |err| {
804809
std.debug.print("CDP server error: {}", .{err});
805810
return err;
806811
};

0 commit comments

Comments
 (0)