Hey, I'm trying to adopt vscode+rust-analyzer instead of my beloved emacs for some chalk hacking. I have a kind of silly question. How do I run tests? I can go to the Terminal and do
cargo test --all but I was hoping there is some more "integrated" way for me to do this. (Chalk's tests in particular are mostly in a
In any case is there a way to run cargo test via some shortcut or something?
Ah, I do see a "run test" popup highlighted over
I guess that will do
@nikomatsakis I'd recommend using this extension to run a test in a debugger. There is some work on merging this functionality to rust-analyzer. Beware that you also need
vscode-lldb debug adapter extension to make it happen.
Side note that powershell doesn't seem to support
FOO=BAR notation for setting environment variables for a single command; that's annoying
@nikomatsakis I generally use
Rust Analyzer: Run which runs a single test/single test module at the cursor. It doesn't have a shortctut by default, but it's a good idea to assign one
For running the whole test suite, I just run
cargo qt in an external terminal.
I'd love to add an ability to run a cargo command with completion for arguments (which would be smarter than bash completion, b/c it can suggest packages for -p argument). This feature is implemented in IntelliJ, but VS Code I think lacks the necessary UI for it.
Also note that
Rust Analyzer: Run remembers the last test you've run. So my typical workflow is:
Coincidentally, the bot just said that the request for "command with completion for arguments" goes to vscode backlog: https://github.com/microsoft/vscode/issues/35785#issuecomment-478551918 :)
It actually said the issue hasn't received enough upvotes yet. There are 10 more days to upvote.
I think we're already able to create something like this in VS Code:
React on the input text change, propose the autocompleted options below, remember the input to be able to rerun the action with it (I think the last item is done by VS Code automatically)
I sometimes miss the possibility to constantly rerun the
cargo check --all-targets or
cargo clippy while iteratively fixing all the issues that pop up.
If I'm not mistaken, RA will also be able to parse this output to highlight the problems and provide the assists.
(the screenshot is the
Run Cargo Command Action provided by intellij-rust)
@Kirill Bulatov The guy that created the issue referenced by matklad said:
There's also the quick picker, but as far as I know, it doesn't allow you to dynamically update the available options depending on what has been typed in.