rust-lang / rust-lang/rust-analyzer
Run test/debug not working in dependent Crate tests in VSCode
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I have:
project/
Cargo.toml
libs/dep/
Cargo.toml
src/lib.rs
project/Cargo.toml:
[package]
edition = "2021"
name = "placeholder"
version = "0.1.0"
[dependencies]
mydep = { path = "libs/dep" }
If I open libs/dep/ as a separate VSCode project & run a test in src/lib.rs everything works as expected. If I open project/ instead and then try to run a test from libs/dep/src/lib.rs, it fails:
- If I click "Debug test", it prints "could not find Cargo.toml in /home/vlovich or any parent directory"
- If I click "Run test", it runs the test command (Executing task: cargo test -- --exact --nocapture) but I think it's in the
project/folder instead ofproject/libs/depbecause it builds but finds 0 tests to run and it lists "placeholder" as the package that was built.
Ideally I think rust-analyzer would scan up from the current file to find the directory of the Cargo.toml instead of assuming it's the workspace root.
rust-analyzer version: Tried & failed in the same way on 0.4.1242, 0.4.1237, and 0.3.1238. I saw #13404 but this looks like a different issue since it's still present on stable.
rustc version: rustc 1.64.0 (a55dd71d5 2022-09-19)
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTUP_HOME or CARGO_HOME)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with project/Cargo.toml, libs/dep/Cargo.toml, and libs/dep/src/lib.rs open from the workspace root. Compare the Run test and Debug test commands and their working directories for the dependent crate. Done means both commands locate the dependency crate and execute its selected test rather than the root package.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, vscode
- Domain
- devtools, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100