Skip to content

Commit

Permalink
FIX: In discovery mode cargo keep the order of test cases
Browse files Browse the repository at this point in the history
...by iterating keys in the same order as `cargo nextest` spits them out
  • Loading branch information
gollth committed Oct 25, 2023
1 parent 94b1efd commit 32b1089
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lua/neotest-rust/discovery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,10 @@ function M.cargo(path, positions, name_mapper)
local tests = {}
for key, value in pairs(json["rust-suites"]) do
tests[key] = {}
for case, _ in pairs(value["testcases"]) do
for case in pairs(value["testcases"]) do
table.insert(tests[key], case)
end
table.sort(tests[key])
end
local target = binary_name(path)
if target == nil then
Expand All @@ -299,7 +300,7 @@ function M.cargo(path, positions, name_mapper)
for _, value in positions:iter_nodes() do
local data = value:data()
if data.type == "test" and data.parameterization ~= nil then
for _, case in pairs(tests[target]) do
for _, case in ipairs(tests[target]) do
if case:match("^" .. data.id .. "::") then
-- `case` is a parameterized version of `value`, so add it as child
local name = name_mapper(case:gsub("^" .. data.id .. "::", ""), data.parameterization, path)
Expand Down

0 comments on commit 32b1089

Please sign in to comment.