rust-lang / rust-lang/rust-analyzer
Configure test runner to use vendor directory
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
In my workspace project we use vendored dependencies in the vendor directory, but we do not add the replace-with configuration in the .cargo/config.toml because doing so effectively cuts off all access to crates.io. Instead we use aliases for build and test that set the replacement for those commands e.g.:
test-vendor = [
"test",
"--config",
"source.vendored-sources.directory='vendor'",
"--config",
"source.crates-io.replace-with='vendored-sources'",
"--locked",
]
I'd like to be able to replicate something like this in rust-analyzer in VS Code for running tests.
What I've tried:
- Creating a supplemental
config.vendor.tomlwith the required source settings and setting--config .cargo/config.vendor.tomlinrust-analyzer.cargo.extraArgs - Setting the
--config source.vendored-sources...etc, inrust-analyzer.cargo.extraArgs - Setting:
"rust-analyzer.cargo.extraEnv": {
"CARGO_SOURCE_VENDORED_SOURCES_DIRECTORY": "vendor",
"CARGO_SOURCE_CRATES_IO_REPLACE_WITH": "vendored-sources"
}
- Setting:
"rust-analyzer.cargo.cfgs": {
"source.crates-io.replace-with": "vendored-sources",
"source.vendored-sources.directory": "vendor"
}
- Creating a
launch.jsonand adding either the--configwith a path or with the key/value pairs to the cargo args tables.
Is there any way of specifying additional arguments to pass to the invocation of cargo test?
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
No source files or tests are named. Start by reading rust-analyzer's cargo configuration and VS Code test-runner documentation, then trace how cargo test is invoked and how cargo.extraArgs is applied. Done means users can supply additional cargo test arguments, including the requested --config settings, for test runs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100