@@ -6,18 +6,10 @@ local dotnet_utils = require("neotest-vstest.dotnet_utils")
66local M = {}
77
88function M .get_vstest_path ()
9- local path_to_search = vim .g .neotest_vstest .sdk_path
9+ local path_to_search = vim .g .neotest_vstest and vim . g . neotest_vstest .sdk_path
1010
1111 if not path_to_search then
12- local process = nio .process .run ({
13- cmd = " dotnet" ,
14- args = { " --info" },
15- })
16-
17- logger .debug (
18- " neotest-vstest: starting process to detect dotnet sdk path "
19- .. tostring (process and process .pid or 0 )
20- )
12+ local process = vim .system ({ " dotnet" , " --info" })
2113
2214 local default_sdk_path
2315 if vim .fn .has (" win32" ) then
@@ -26,35 +18,22 @@ function M.get_vstest_path()
2618 default_sdk_path = " /usr/local/share/dotnet/sdk/"
2719 end
2820
29- if not process then
21+ local obj = process :wait ()
22+
23+ local out = obj .stdout
24+ local info = dotnet_utils .parse_dotnet_info (out or " " )
25+ if info .sdk_path then
26+ path_to_search = info .sdk_path
27+ logger .info (string.format (" neotest-vstest: detected sdk path: %s" , path_to_search ))
28+ else
3029 path_to_search = default_sdk_path
3130 local log_string = string.format (
3231 " neotest-vstest: failed to detect sdk path. falling back to %s" ,
33- default_sdk_path
32+ path_to_search
3433 )
35-
3634 logger .info (log_string )
3735 nio .scheduler ()
3836 vim .notify_once (log_string )
39- else
40- local out = process .stdout .read ()
41- local info = dotnet_utils .parse_dotnet_info (out or " " )
42- if info .sdk_path then
43- path_to_search = info .sdk_path
44- logger .info (
45- string.format (" neotest-vstest: detected sdk path: %s" , vim .g .neotest_vstest .sdk_path )
46- )
47- else
48- path_to_search = default_sdk_path
49- local log_string = string.format (
50- " neotest-vstest: failed to detect sdk path. falling back to %s" ,
51- path_to_search
52- )
53- logger .info (log_string )
54- nio .scheduler ()
55- vim .notify_once (log_string )
56- end
57- process .close ()
5837 end
5938 end
6039
7655--- @return { execute : fun ( content : string ), stop : fun () }
7756function M .create_test_runner (project )
7857 local test_discovery_script = get_script (" run_tests.fsx" )
79- local testhost_dll = get_vstest_path ()
58+ local testhost_dll = M . get_vstest_path ()
8059
8160 logger .debug (" neotest-vstest: found discovery script: " .. test_discovery_script )
8261 logger .debug (" neotest-vstest: found testhost dll: " .. testhost_dll )
0 commit comments