Skip to content

Commit c36b409

Browse files
committed
Merge branch 'main' into feat/unified_options_table
2 parents 1ff83ca + 1cb733b commit c36b409

File tree

5 files changed

+18
-47
lines changed

5 files changed

+18
-47
lines changed

lua/neotest-vstest/health.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ M.check = function()
44

55
vim.health.info("checking for dependencies...")
66

7-
local has_nio = pcall(require("nio"))
7+
local has_nio, nio = pcall(require, "nio")
88
if not has_nio then
99
vim.health.error("nio is not installed. Please install nio to use neotest-vstest.")
1010
else
1111
vim.health.ok("nio is installed.")
1212
end
1313

14-
local has_neotest = pcall(require("neotest"))
14+
local has_neotest = pcall(require, "neotest")
1515
if not has_neotest then
1616
vim.health.error("neotest is not installed. Please install neotest to use neotest-vstest.")
1717
else

lua/neotest-vstest/init.lua

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -584,16 +584,7 @@ local DotnetNeotestAdapter = create_adapter()
584584

585585
---@param opts neotest-vstest.Config
586586
local function apply_user_settings(_, opts)
587-
if opts then
588-
vim.g.neotest_vstest.sdk_path = opts.sdk_path or vim.g.neotest_vstest.sdk_path
589-
vim.g.neotest_vstest.build_opts = opts.build_opts or vim.g.neotest_vstest.build_opts
590-
vim.g.neotest_vstest.dap_settings = opts.dap_settings or vim.g.neotest_vstest.dap_settings
591-
vim.g.neotest_vstest.solution_selector = opts.solution_selector
592-
or vim.g.neotest_vstest.solution_selector
593-
vim.g.neotest_vstest.find_settings = opts.settings_selector
594-
or vim.g.neotest_vstest.find_settings
595-
vim.g.neotest_vstest.timeout_ms = opts.timeout_ms or vim.g.neotest_vstest.timeout_ms
596-
end
587+
vim.g.neotest_vstest = vim.tbl_deep_extend("force", vim.g.neotest_vstest or {}, opts or {})
597588
return create_adapter(opts)
598589
end
599590

lua/neotest-vstest/vstest/cli_wrapper.lua

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,10 @@ local dotnet_utils = require("neotest-vstest.dotnet_utils")
66
local M = {}
77

88
function 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

@@ -76,7 +55,8 @@ end
7655
---@return { execute: fun(content: string), stop: fun() }
7756
function M.create_test_runner(project)
7857
local test_discovery_script = get_script("run_tests.fsx")
79-
local testhost_dll = get_vstest_path()
58+
nio.scheduler()
59+
local testhost_dll = M.get_vstest_path()
8060

8161
logger.debug("neotest-vstest: found discovery script: " .. test_discovery_script)
8262
logger.debug("neotest-vstest: found testhost dll: " .. testhost_dll)

lua/neotest-vstest/vstest/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function Client:new(project)
2222
logger.info("neotest-vstest: Creating new (vstest) client for: " .. vim.inspect(project))
2323
local findSettings = function()
2424
local settings = nil
25-
if vim.g.neotest_vstest.find_settings then
25+
if vim.g.neotest_vstest and vim.g.neotest_vstest.find_settings then
2626
settings = vim.g.neotest_vstest.find_settings(project.proj_dir)
2727
end
2828
if settings ~= nil then

scripts/run_tests.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ module TestDiscovery =
239239
do
240240
Console.WriteLine($"spawned test process with pid: {pid}")
241241
use pidWriter = new StreamWriter(pidFile, append = false)
242-
pidWriter.WriteLine(pid)
242+
pidWriter.Write(pid)
243243

244244
while not (cts.Token.IsCancellationRequested || File.Exists(attachedFile)) do
245245
()

0 commit comments

Comments
 (0)