Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(neotest): pass --color argument to neotest adaper #557

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
14 changes: 12 additions & 2 deletions lua/rustaceanvim/neotest/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,18 @@ function NeotestAdapter.build_spec(run_args)
table.insert(args, insert_pos, '--no-fail-fast')
table.insert(args, insert_pos, '--color=never')
if is_cargo_test then
-- cargo test needs to pass --color=never to the test runner too
table.insert(args, '--color=never')
-- filter args at any position
local filtered = vim.tbl_filter(function(v)
return string.match(v, '^--color=')
end, runnable.args.cargoArgs)

if not vim.tbl_isempty(filtered) then
-- add first occurrence of filter argument contain --color
table.insert(args, filtered[0])
else
-- cargo test needs to pass --color=never to the test runner too
table.insert(args, '--color=never')
end
Comment on lines +303 to +313
Copy link
Owner

@mrcjkb mrcjkb Nov 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local filtered = vim.tbl_filter(function(v)
return string.match(v, '^--color=')
end, runnable.args.cargoArgs)
if not vim.tbl_isempty(filtered) then
-- add first occurrence of filter argument contain --color
table.insert(args, filtered[0])
else
-- cargo test needs to pass --color=never to the test runner too
table.insert(args, '--color=never')
end
---@type string | nil
local color_arg = vim.iter(runnable.args.cargoArgs):find(function(arg)
return string.match(arg, '^--color=') ~= nil
end)
if color_arg then
table.insert(args, color_arg)
else
-- cargo test needs to pass --color=never to the test runner too
table.insert(args, '--color=never')
end

end
---@type rustaceanvim.neotest.RunSpec
---@diagnostic disable-next-line: missing-fields
Expand Down