Skip to content

Commit 2184260

Browse files
waynebowie99pcius-waynebNsidorenco
authored
Fixes an issue with the dotnet executable not being killed (#34)
* Fixes an issue with the dotnet executable not being killed * Returning the mtp_process.pid * Set timeout for test discovery + added log for error * formatting --------- Co-authored-by: Wayne Bowie <[email protected]> Co-authored-by: nsidorenco <[email protected]>
1 parent 5e22a2e commit 2184260

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

lua/neotest-vstest/mtp/client.lua

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local M = {}
88
---@async
99
---@param dll_path string path to test project dll file
1010
---@param mtp_env? table<string, string> environment variables for the mtp server
11-
---@return nio.control.Future<uv.uv_tcp_t> server_future, integer mtp_process_pid
11+
---@return nio.control.Future<uv.uv_tcp_t> server_future, vim.SystemObj mtp_process
1212
local function start_server(dll_path, mtp_env)
1313
local server, server_err = vim.uv.new_tcp()
1414
assert(server, server_err)
@@ -33,7 +33,9 @@ local function start_server(dll_path, mtp_env)
3333
logger.debug("neotest-vstest: Accepted connection from mtp")
3434
mtp_client = client
3535
client:read_start(function(err, data)
36-
assert(not err, err)
36+
if err then
37+
logger.warn("neotest-vstest: " .. err)
38+
end
3739
if data then
3840
logger.trace("neotest-vstest: Received data from mtp with pid: " .. data)
3941
lsp_client:write(data)
@@ -76,7 +78,7 @@ local function start_server(dll_path, mtp_env)
7678

7779
logger.debug("neotest-vstest: MTP process started with PID: " .. process.pid)
7880

79-
return server_future, process.pid
81+
return server_future, process
8082
end
8183

8284
local random = math.random
@@ -95,7 +97,7 @@ end
9597
---@param mtp_env? table<string, string> environment variables for the mtp server
9698
---@return nio.control.Future<vim.lsp.Client> client_future, integer mtp_process_pid
9799
function M.create_client(dll_path, on_update, on_log, mtp_env)
98-
local server_future, mtp_process_pid = start_server(dll_path, mtp_env)
100+
local server_future, mtp_process = start_server(dll_path, mtp_env)
99101
local client_future = nio.control.future()
100102

101103
nio.run(function()
@@ -105,7 +107,11 @@ function M.create_client(dll_path, on_update, on_log, mtp_env)
105107
cmd = vim.lsp.rpc.connect(server:getsockname().ip, server:getsockname().port),
106108
root_dir = vim.fs.dirname(dll_path),
107109
on_exit = function()
110+
logger.debug(
111+
"neotest-vstest: MTP process shutdown triggered from client with PID: " .. mtp_process.pid
112+
)
108113
server:shutdown()
114+
mtp_process:kill(9)
109115
end,
110116
before_init = function(params)
111117
params.processId = vim.fn.getpid()
@@ -135,7 +141,7 @@ function M.create_client(dll_path, on_update, on_log, mtp_env)
135141
client_future.set(client)
136142
end)
137143

138-
return client_future, mtp_process_pid
144+
return client_future, mtp_process.pid
139145
end
140146

141147
---@async
@@ -153,6 +159,7 @@ function M.discovery_tests(dll_path)
153159

154160
local client_future = M.create_client(dll_path, on_update, function() end)
155161

162+
--@type vim.lsp.Client
156163
local client = client_future.wait()
157164

158165
nio.scheduler()
@@ -161,7 +168,7 @@ function M.discovery_tests(dll_path)
161168
local run_id = uuid()
162169
client:request_sync("testing/discoverTests", {
163170
runId = run_id,
164-
})
171+
}, 30000)
165172

166173
logger.debug("neotest-vstest: Discovered test results: " .. vim.inspect(tests))
167174

lua/neotest-vstest/vstest/cli_wrapper.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function M.create_test_runner(project)
111111
process:write(content .. "\n")
112112
end,
113113
stop = function()
114-
process:kill(0)
114+
process:kill(9)
115115
end,
116116
}
117117
end

0 commit comments

Comments
 (0)