Skip to content

Conversation

@winter-loo
Copy link

This patch is to check the type of spec.strategy before the async runners. Before this patch, when an adapter provider does not return the correct type of spec.stragegy, neotest will raise the exception below:

image

NOTE the error after the second argument: expected table, got string. That error comes from the code:

      vim.tbl_extend("force", spec.strategy or {}, config.strategies[args.strategy] or {})

After this patch, the user will see a better error tip:

image

related commit: mrcjkb/rustaceanvim#803

After the above rustaceanvim fix, neotest gets:

image

This new error tip results in the second commit.

And finally, we get:

image

@winter-loo
Copy link
Author

@OddBloke could this PR be reviewed

Copy link
Collaborator

@rcarriga rcarriga left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Just some small comments

local async_runners = {}
for _, spec in ipairs(specs) do
if not (type(spec.strategy) == "function" or type(spec.strategy) == "table" or spec.strategy == nil) then
self:_run_broken_down_tree(tree, args, adapter_id, adapter, results_callback)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's just raise the error directly here, it's not clear that this is being called just to raise an error

code = instance.result()
end)
if not instance then
error("Adapter doesn't provide a correct strategy")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please keep the original wording of the error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants