From 4f04f7dac0da3893e94e2d9b114cd801a6770d4f Mon Sep 17 00:00:00 2001 From: Lee Cannon Date: Sun, 29 May 2022 18:18:57 +0100 Subject: [PATCH] `std.ChildProcess.init` cannot error --- src/main.zig | 5 ++--- tests/sessions.zig | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main.zig b/src/main.zig index 6ef2a3f..d4a4276 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1454,8 +1454,7 @@ fn formattingHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req: return try respondGeneric(id, null_result_response); }; - var process = try std.ChildProcess.init(&[_][]const u8{ zig_exe_path, "fmt", "--stdin" }, allocator); - defer process.deinit(); + var process = std.ChildProcess.init(&[_][]const u8{ zig_exe_path, "fmt", "--stdin" }, allocator); process.stdin_behavior = .Pipe; process.stdout_behavior = .Pipe; @@ -1656,7 +1655,7 @@ pub fn main() anyerror!void { // Check arguments. var args_it = try std.process.ArgIterator.initWithAllocator(allocator); defer args_it.deinit(); - if(!args_it.skip()) @panic("Could not find self argument"); + if (!args_it.skip()) @panic("Could not find self argument"); var config_path: ?[]const u8 = null; var next_arg_config_path = false; diff --git a/tests/sessions.zig b/tests/sessions.zig index 59118c5..8212d42 100644 --- a/tests/sessions.zig +++ b/tests/sessions.zig @@ -13,7 +13,7 @@ const initialize_msg_offs = ; const Server = struct { - process: *std.ChildProcess, + process: std.ChildProcess, request_id: u32 = 1, fn start(initialization: []const u8, expect: ?[]const u8) !Server { @@ -103,12 +103,11 @@ const Server = struct { // FIXME this shutdown request fails with a broken pipe on stdin on the CI self.request("shutdown", "{}", null) catch @panic("Could not send shutdown request"); // waitNoError(self.process) catch @panic("Server error"); - self.process.deinit(); } }; -fn startZls() !*std.ChildProcess { - var process = try std.ChildProcess.init(&[_][]const u8{"zig-out/bin/zls" ++ suffix}, allocator); +fn startZls() !std.ChildProcess { + var process = std.ChildProcess.init(&[_][]const u8{"zig-out/bin/zls" ++ suffix}, allocator); process.stdin_behavior = .Pipe; process.stdout_behavior = .Pipe; process.stderr_behavior = .Inherit;