@@ -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
1212local 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
8082end
8183
8284local random = math.random
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
9799function 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
139145end
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
0 commit comments