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

Neotest diagnostics #44

Merged
merged 5 commits into from
Jul 1, 2023
Merged

Neotest diagnostics #44

merged 5 commits into from
Jul 1, 2023

Conversation

bram209
Copy link
Contributor

@bram209 bram209 commented Jun 28, 2023

image

resolves #22

For now, I parse rustc panic messages and display the whole message as a diagnostic.
I could imagine that we may want to handle specialised cases for common assert failed messages, like for example: assert_eq could become a compact diagnostic message in vim: left: `2`, right: `3`, but we could add that in another PR (if wanted), thoughts? @rouge8 @igorlfs

@bram209
Copy link
Contributor Author

bram209 commented Jun 28, 2023

Note that I use LazyVim that by default replaces newlines and tabs with spaces to make diagnostic messages from neotest more compact: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/extras/test/core.lua#L43

@igorlfs
Copy link
Contributor

igorlfs commented Jun 28, 2023

I could imagine that we may want to handle specialised cases for common assert failed messages, like for example: assert_eq could become a compact diagnostic message in vim: left: 2, right: 3, but we could add that in another PR (if wanted), thoughts?

I think handling specialized cases would be very welcome!

By the way, would you mind giving me some pointers for implementing this for other adapters? From looking at the code, the main thing seems to be indeed the parse_errors function and the adjustments in adapter.results. Am I missing something?

@bram209
Copy link
Contributor Author

bram209 commented Jun 28, 2023

I could imagine that we may want to handle specialised cases for common assert failed messages, like for example: assert_eq could become a compact diagnostic message in vim: left: 2, right: 3, but we could add that in another PR (if wanted), thoughts?

I think handling specialized cases would be very welcome!

By the way, would you mind giving me some pointers for implementing this for other adapters? From looking at the code, the main thing seems to be indeed the parse_errors function and the adjustments in adapter.results. Am I missing something?

you can set the errors property of a result, how you do that is entirely up to you. For example, in neotest-python (at first glance) looks to call pytest as a library, where they have the ability to access representation of the exception directly:
https://github.com/nvim-neotest/neotest-python/blob/master/neotest_python/pytest.py#L116

In this library I created a module errors.lua that contains the required logic to parse panics from rustc output. parse_errors is not part of the interface that neotest will call into or anything like that.

@rouge8 rouge8 merged commit 6dce896 into rouge8:main Jul 1, 2023
@igorlfs
Copy link
Contributor

igorlfs commented Nov 15, 2023

This is kinda broken to me in the latest version. Is this working for any of you?

@rouge8
Copy link
Owner

rouge8 commented Dec 4, 2023

@igorlfs it looks like the output format has changed. can you open a new issue to track this? it should be a simple fix to https://github.com/rouge8/neotest-rust/blob/main/lua/neotest-rust/errors.lua and https://github.com/rouge8/neotest-rust/blob/main/tests/errors_spec.lua#L12 . I'm not writing much Rust these days so I probably won't get to it anytime soon, but PRs are welcome!

@igorlfs
Copy link
Contributor

igorlfs commented Dec 4, 2023

Hey @rouge8!

I opened a PR #64 ! It might need some adjustments, though

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.

Feature Request: support diagnostic messages
3 participants