Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions lua/neotest/client/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,9 @@ function TestRunner:run_tree(tree, args, adapter_id, adapter, on_results)
end
end

fill_results(self:_missing_results(root, results, not output_path))
fill_results(self:_missing_results(root, results, true))

if output_path then
for _, pos in root:iter() do
if not results[pos.id] and not all_results[pos.id] then
results[pos.id] = {
status = "failed",
errors = {},
output = output_path,
}
end
end

for _, result in pairs(results) do
if not result.output then
result.output = output_path
Expand All @@ -63,6 +53,8 @@ function TestRunner:run_tree(tree, args, adapter_id, adapter, on_results)
args = vim.tbl_extend("keep", args or {}, { strategy = config.projects[root].default_strategy })

self:_run_tree(tree, args, adapter_id, adapter, results_callback)
all_results =
vim.tbl_extend("force", all_results, self:_missing_results(tree, all_results, false))

self._running[tree:data().id] = nil
return all_results
Expand Down Expand Up @@ -254,6 +246,7 @@ function TestRunner:_missing_results(tree, results, partial)

if pos_result.status ~= "skipped" and parent_result.status == "passed" then
parent_result.status = pos_result.status
parent_result.output = pos_result.output
end

results_proxy[parent_pos.id] = parent_result
Expand Down Expand Up @@ -287,7 +280,7 @@ function TestRunner:_missing_results(tree, results, partial)
results_proxy[pos.id] = { status = "skipped" }
elseif pos.type ~= "dir" and not results_proxy[pos.id] and root_result then
-- Tests and namespaces not being present means that they failed to even start, count as root result
results_proxy[pos.id] = { status = root_result.status }
results_proxy[pos.id] = { status = root_result.status, output = root_result.output }
end
end
end
Expand Down
49 changes: 48 additions & 1 deletion tests/unit/client/init_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,54 @@ describe("neotest client", function()
end
end)

a.it("fills test and namespace results fromm failed files", function()
a.it("fills output from child tests", function()
local tree = get_pos(dir .. "/test_file_1")
exit_future.set()
client:run_tree(tree, { strategy = mock_strategy })
local adapter_id = client:get_adapters()[1]
local results = client:get_results(adapter_id)
for _, pos in tree:iter() do
assert.equal(results[pos.id].output, "not_a_file")
end
end)

a.it("fills test and namespace results from different output", function()
mock_adapter.build_spec = function()
return {
{ strategy = { output = "test_file_1" } },
{ strategy = { output = "test_file_2" } },
}
end

mock_adapter.results = function(_, process, tree)
local results = {}
for _, pos in tree:iter() do
if pos.type == "test" then
if pos.id:find(process.output) then
results[pos.id] = {
status = "success",
}
end
end
end
return results
end

local tree = get_pos(dir)
exit_future.set()
client:run_tree(tree, { strategy = mock_strategy })
local adapter_id = client:get_adapters()[1]
local results = client:get_results(adapter_id)
assert.equal(9, #vim.tbl_keys(results))
for id, result in pairs(results) do
if id ~= dir then
assert.Not.Nil(id:find(result.output))
end
assert.equal("success", result.status)
end
end)

a.it("fills test and namespace results from failed files", function()
mock_adapter.results = function(_, _, tree)
local results = {}
for _, pos in tree:iter() do
Expand Down