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 cargo {test,doc,...} --all-features #1173

Closed
tomaka opened this issue Jan 15, 2015 · 6 comments
Closed

Add cargo {test,doc,...} --all-features #1173

tomaka opened this issue Jan 15, 2015 · 6 comments
Labels
A-features Area: features — conditional compilation

Comments

@tomaka
Copy link
Contributor

tomaka commented Jan 15, 2015

When running tests on travis, you usually want to enable all the features when running cargo test. However this requires manually passing all non-default-features one-by-one. It is easy to forget one.

An option should be added to enable all the features.

The follow-up should be to submit a PR or open an issue to travis so that its engine runs cargo test --verbose --all-features instead of just cargo test --verbose by default.

@tomaka tomaka changed the title Add cargo {test,doc} --all-features Add cargo {test,doc,...} --all-features Jan 15, 2015
@alexcrichton alexcrichton added the A-features Area: features — conditional compilation label Jan 16, 2015
@SimonSapin
Copy link
Contributor

I’d also like cargo test without argument to default to testing with a multiple sets of features specified in Cargo.toml. Currently I have a Makefile to test both with and without a feature, but I never remember to actually use it locally. (Travis-CI uses it, though.)

test:
    cargo test --features query_encoding
    cargo test

@shepmaster
Copy link
Member

An option should be added to enable all the features.

Hmm. What about combinations of features? for example

[features]
a = []
b = []

Would there be 3 runs:

  1. --features ""
  2. --features "a"
  3. --features "b"

Or also a fourth?

  1. --features "a b"

@alexcrichton
Copy link
Member

I'd personally expect this to just pass --features "a b" in that case, re-running all the tests may be a bit much.

@SimonSapin
Copy link
Contributor

Since Cargo doesn’t know how features interact with each other, I think this should be left to the library author. The default would be a single run with no features enabled (unless given on the command line), but Cargo.toml could specify multiple runs, and for each of them the set of features to enable.

[lib]
test_features = [[], ["query_encoding"]]
[lib]
test_features = [[], ["a"], ["b"], ["a", "b"]]

@esclear
Copy link
Contributor

esclear commented Aug 24, 2016

I'm currently working on implementing support for a basic --all-features flag.
The scope of my approach to it (just enabling all flags for the project / crate) is not with @SimonSapin's proposal, which might also involve #2980.

I personally would prefer doing what seems most intuitive, just enabling all features.
Having specific feature sets could be nice as well, but I think that this flag would be most useful for building documentation or installing certain binaries.
Testing is obviously another possible use case, but I don't think that a test (as part of a feature) that requires another feature being disabled is not that feasible.

@esclear
Copy link
Contributor

esclear commented Aug 24, 2016

Implemented in #3038, but without special feature sets for testing.

bors added a commit that referenced this issue Aug 31, 2016
Add --all-features flag to cargo

As (more or less) requested in #1173 I added a `--all-features` flag to cargo that builds all available features.

I hope I documented it in all the right places.

If there's something weird or wrong, please give me a heads up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-features Area: features — conditional compilation
Projects
None yet
Development

No branches or pull requests

5 participants