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

Ability to test against registry dependencies, instead of path dependencies #14429

Open
barakugav opened this issue Aug 20, 2024 · 1 comment
Labels
A-dependency-resolution Area: dependency resolution and the resolver C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-package Command-test S-triage Status: This issue is waiting on initial triage.

Comments

@barakugav
Copy link

Problem

I have a monorepo with multiple Rust crates that depends on one another with both a path and version dependency. An example for a line in Cargo.toml:

my_crate_dep = {path = "../my_crate_dep", version="1.0.0"}

The behaviour of cargo to ignore the version during development and ignore the path during publish or package is amazing! When I run cargo package the crate it built with my_crate_dep from crates.io, and not my local dependency.
I would also like to cargo test with my_crate_dep from crates.io rather than local, in addition to the build.

Proposed Solution

One of the following will provide what I need:

  • Add a flag to cargo test indicating to ignore path/git dependencies, maybe along the lines of --force-published-deps.
  • Add a flag to cargo package to run tests

Notes

Actually I think such flags can be useful in many sub commands of cargo, maybe we should consider a wide option

@barakugav barakugav added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Aug 20, 2024
@epage epage changed the title cargo test while ignoring path dependencies Ability to opt-in to registry dependencies, instead of path dependencies, for cargo test Aug 20, 2024
@epage epage added Command-test A-dependency-resolution Area: dependency resolution and the resolver Command-package labels Aug 20, 2024
@epage epage changed the title Ability to opt-in to registry dependencies, instead of path dependencies, for cargo test Ability to test agai Aug 20, 2024
@epage epage changed the title Ability to test agai Ability to test against registry dependencies, instead of path dependencies Aug 20, 2024
@epage
Copy link
Contributor

epage commented Aug 20, 2024

I've brought up a similar idea for cargo hack at taiki-e/cargo-hack#216.

I've also wondered about the ability to do cargo test --manifest-path foo.crate

The big challenge is when the registry versions of the packages are insufficient. maybe #10948 combined with -Zminimal-versions would make it so we could have all of the .crate files but only use when when absolutely necessary. Callers would still need a way to make them available. The way cargo packages verify step is doing it is internal-only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dependency-resolution Area: dependency resolution and the resolver C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-package Command-test S-triage Status: This issue is waiting on initial triage.
Projects
Status: No status
Development

No branches or pull requests

2 participants