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.cargo.allTargets = true doesn't include "test = false" integration test targets #19395

Open
Sushisource opened this issue Mar 18, 2025 · 2 comments
Labels
C-bug Category: bug

Comments

@Sushisource
Copy link

Sushisource commented Mar 18, 2025

I'm finding that rust-analyzer doesn't run in and provide diagnostics/completes/etc for non-default integration test targets (see code snippet below for what exactly I mean by that). I would expect it do do so when the allTargets setting in the title is enabled, but even beyond that, I can't seem to find any way to instruct it to explicitly inspect such targets (which would be a good option to have too). I have these targets use test = false because I don't want them to run with my normal unit tests as part of cargo test. Instead, I have a small wrapper binary that I call via an alias that passes the right --features and --test flags to cargo test in order to explicitly run it (it also spawns a server process my integration tests depend on).

So:

  1. Should allTargets include these? If so, currently that seems to be bugged, if no, why not?
  2. Is there some existing setting to tell rust-analyzer to include this target? If not, can one be added?

I can confirm that if I remove test = false from the [[test]] section in my Cargo.toml for this test that rust-analyzer starts working as expected.

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

rust-analyzer 1.85.0 (4d91de4 2025-02-17)

rustc version: (eg. output of rustc -V)
rustc 1.85.0 (4d91de4e4 2025-02-17)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)

Zed

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

repository link (if public, optional): (eg. rust-analyzer)
https://github.com/temporalio/sdk-core -- specifically here

code snippet to reproduce:

[[test]]
name = "some_integ_test"
path = "tests/some_integ_test.rs"
test = false
required-features = ["some-non-default-feature"]
@Sushisource Sushisource added the C-bug Category: bug label Mar 18, 2025
@Veykril
Copy link
Member

Veykril commented Mar 19, 2025

the all targets option just means passing --all-targets to cargo, so this is standard cargo behavior that you are observing here. Your setup sounds non-standard so you might wanna make use of rust-analyzer.check.overrideCommand.

@Sushisource
Copy link
Author

Sushisource commented Mar 19, 2025

@Veykril Thanks! That does get me a way to make it work, by passing --test some_integ_test as additional arguments to the override command.

I think it's probably not ideal still, though. I'm forced to add one of those for any test I have which is non-default like this (which is yes "non-standard" in some sense, but I don't think tremendously uncommon for integration tests), and from a UX perspective I'd imagine the analyzer ought to default to working pretty much everywhere, with options to stop it if needed, rather than the inverse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants