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

Rust-Analyzer's "Run test" buttons don't work with defmt-test #260

Closed
japaric opened this issue Nov 16, 2020 · 3 comments · Fixed by knurling-rs/probe-run#151
Closed

Rust-Analyzer's "Run test" buttons don't work with defmt-test #260

japaric opened this issue Nov 16, 2020 · 3 comments · Fixed by knurling-rs/probe-run#151
Assignees
Labels
status: blocked Blocked on another issue, or on upstream libraries type: enhancement Enhancement or feature request

Comments

@japaric
Copy link
Member

japaric commented Nov 16, 2020

The #[test] attribute is picked up by Rust-Analyzer so RA shows "Run Test" buttons but you get an error if you try to use.
Those button will invoke cargo test --package testsuite --test test -- tests::assert_true --exact --nocapture which then invokes passes the tests::assert_true --exact --nocapture arguments to probe-run.
probe-run will fail to run as it doesn't recognize those command line arguments.
Interestingly the mod tests module is also picked up by RA so it also gets a "Run Test" button; that one also fails to run.

2020-09-08-155154

(migrated from knurling-rs/defmt-test#1 )

@japaric japaric added type: enhancement Enhancement or feature request status: blocked Blocked on another issue, or on upstream libraries labels Nov 16, 2020
@Lotterleben
Copy link
Contributor

on what is this issue blocked?

@japaric
Copy link
Member Author

japaric commented Dec 7, 2020

on what is this issue blocked?

being able to customize the behavior of "Run Test" in Rust Analyzer maybe? RA assumes the standard (std) test runner will be used: that's why it passes those extra command line flags (which probe-run doesn't recognize). That's a fair thing to assume given that #[test] is only available in std on the stable channel. defmt-test is pretending to be the standard #[test] attribute; hence the mismatch. If RA had an option to stop passing these flags then we could fix this in app-template by shipping some JSON file to configure RA.

I guess the other way to make this work is to make probe-run ignore these extra flags if it's being used to run tests but that would be kind of hacky.

@Lotterleben
Copy link
Contributor

Ah! Thank you for the detailed explanation.
To me, the hacky fix actually seems nicer from the outside: If you don't look under the bonnet, things just work (no "put these JSON files there to make this work", which is part of the rust ecosystem magic for me) plus we don't have to wait for R-A to maybe introduce test flag configuration someday.

@japaric japaric self-assigned this Feb 15, 2021
japaric added a commit to knurling-rs/probe-run that referenced this issue Feb 15, 2021
including unknown flags
fixes knurling-rs/defmt#260

which results in `probe-run` being invoked like this:
`probe-run --chip CHIP some-elf module::path --exact --capture`
the last 3 flags are now accepted by the parser but then discarded
bors bot added a commit to knurling-rs/probe-run that referenced this issue Feb 15, 2021
151: discard arguments that come after the ELF file path r=jonas-schievink a=japaric

including unknown flags
fixes knurling-rs/defmt#260

which results in `probe-run` being invoked like this:
`probe-run --chip CHIP some-elf module::path --exact --capture`
the last 3 flags are now accepted by the parser but then discarded

Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: blocked Blocked on another issue, or on upstream libraries type: enhancement Enhancement or feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants