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

Configure test runner to use vendor directory #17198

Open
nine9ths opened this issue May 7, 2024 · 0 comments
Open

Configure test runner to use vendor directory #17198

nine9ths opened this issue May 7, 2024 · 0 comments
Labels
C-support Category: support questions

Comments

@nine9ths
Copy link

nine9ths commented May 7, 2024

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.toml with the required source settings and setting --config .cargo/config.vendor.toml in rust-analyzer.cargo.extraArgs
  • Setting the --config source.vendored-sources... etc, in rust-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.json and adding either the --config with 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?

@nine9ths nine9ths added the C-support Category: support questions label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-support Category: support questions
Projects
None yet
Development

No branches or pull requests

1 participant