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

Add a warning when running cargo test -p on an optional dependency #683

Closed
tomaka opened this issue Oct 8, 2014 · 9 comments
Closed

Add a warning when running cargo test -p on an optional dependency #683

tomaka opened this issue Oct 8, 2014 · 9 comments

Comments

@tomaka
Copy link
Contributor

tomaka commented Oct 8, 2014

Example Cargo.toml:

[package]
name = "test"
version = "0.0.1"
authors = []

[dependencies.sub]
path = "sub"
optional = true

Running cargo test -p sub leads to package id specification "sub" matched no packages.

Removing optional = true or adding [features] default = [ "sub" ] removes the error.

@tomaka tomaka changed the title The cargo test -p command doesn't work for optional dependencies The cargo test -p command doesn't work for optional dependencies that are not default Oct 8, 2014
@alexcrichton
Copy link
Member

This is currently working as expected, the argument to -p is a package id specification, which is run over a certain dependency graph resolution. When you run cargo test -p sub it'll build a dependency graph for the main package, and then search for sub. This doesn't, however, include sub as its an optional feature.

@tomaka
Copy link
Contributor Author

tomaka commented Oct 10, 2014

Oh, I need to run cargo test -p sub --features "sub"?

Now that you're saying it, that seems logical.

@tomaka tomaka closed this as completed Oct 10, 2014
@alexcrichton
Copy link
Member

Yeah, does that seem ok to you? We could possibly run the specification over the entire dependency graph if it's too painful.

@tomaka
Copy link
Contributor Author

tomaka commented Oct 10, 2014

I think that there should at least be some kind of warning. For example searching through the list of features to see if it matches something.

@alexcrichton
Copy link
Member

I'm fine leaving this open to track adding a warning as well (or opening a separate issue on that)

@tomaka tomaka reopened this Oct 10, 2014
@tomaka tomaka changed the title The cargo test -p command doesn't work for optional dependencies that are not default Add a warning when running cargo test -p on an optional dependency Oct 10, 2014
@tomaka
Copy link
Contributor Author

tomaka commented Oct 11, 2014

Yeah, does that seem ok to you?

Actually it doesn't work, because features cannot be modified when the main package is not being built.

I get this message even when I run cargo build --feature "sub" followed by cargo test -p sub --feature "sub".
(see this travis build)

@alexcrichton
Copy link
Member

Ah yes that's right, I forgot about that...

@stale
Copy link

stale bot commented Sep 21, 2018

As there hasn't been any activity here in a while would someone (the author, a team member, or any interested party) be able to summarise the current state, perhaps making explicit:

  • Is this still relevant?
  • If so, what is blocking it?
  • Is it known what could be done to help move this forward?

Thank you!

(The cargo team is currently evaluating the use of Stale bot, and using #6035 as the tracking issue to gather feedback.)

If you're reading this comment from the distant future, fear not if this was closed automatically. If you believe it's still an issue please leave a comment and a team member can reopen this issue. Opening a new issue is also acceptable!

@stale stale bot added the stale label Sep 21, 2018
@stale
Copy link

stale bot commented Oct 21, 2018

As I didn't see any updates in 30 days I'm going to close this. Please see the previous comment for more information!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants