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 --no-examples switch to cargo test #5387

Closed
faulesocke opened this issue Apr 18, 2018 · 5 comments · Fixed by #6619
Closed

Add a --no-examples switch to cargo test #5387

faulesocke opened this issue Apr 18, 2018 · 5 comments · Fixed by #6619
Assignees
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@faulesocke
Copy link

faulesocke commented Apr 18, 2018

cargo test has an --examples switch which checks "that all examples compile". However, this seems to be the default when running cargo test, which makes the switch effectively a no-op.

But sometimes when I do refactoring, I first wan't to check whether all library tests run and then I want to fix the examples. Therefore, having a --no-examples switch would be really helpful.

@alexcrichton alexcrichton added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Apr 18, 2018
@joshtriplett
Copy link
Member

This seems reasonable. If you'd be interested in writing a PR, we'd likely accept it.

@ehuss
Copy link
Contributor

ehuss commented May 14, 2018

--examples is not a no-op. It tests only examples, nothing else.

One approach to skip examples is to do cargo test --lib which will just do unit tests.

Starting in Rust 1.27 (beta), you can also do unit tests and integration tests (without examples) with cargo test --tests --lib.

@joshtriplett
Copy link
Member

@ehuss Thanks for the clarification! In that case, perhaps what we need here is just an added sentence in the documentation, pointing people to the relevant options.

@ehuss
Copy link
Contributor

ehuss commented May 14, 2018

@joshtriplett I've been thinking for a while now about writing more detailed documentation about the default target and profile selection, and how target options like --tests work. I'm not sure how extensive it would be, or where it would live. I'd be reluctant to put it in --help since most commands already have a long stream of unorganized paragraphs. I was thinking maybe a new chapter in the Cargo Book. But if it is buried away somewhere where nobody will see it, it might not be useful. I haven't gotten very far in organizing my thoughts, though. I was thinking about hitting up the cargo team and/or docs team to see what people thought, but I haven't gotten around to it.

@faulesocke
Copy link
Author

@ehuss Thank you very much! Shall I leave the issue open for tracking possible documentation changes or shall I close it?

@dwijnand dwijnand self-assigned this Feb 3, 2019
bors added a commit that referenced this issue Feb 4, 2019
In cargo test's help, add that examples are built

Also clarify that --lib runs the library's unit tests.

Closes #5387
@bors bors closed this as completed in #6619 Feb 4, 2019
pyrossh pushed a commit to pyrossh/rust-embed that referenced this issue Aug 24, 2021
Once Rust 1.27 is released we can use a more general command for both
unit and integration tests:
```
cargo test --tests --lib
```
rust-lang/cargo#5387 (comment)

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
pyrossh pushed a commit to pyrossh/rust-embed that referenced this issue Aug 24, 2021
Once Rust 1.27 is released we can use a more general command for both
unit and integration tests:
```
cargo test --tests --lib
```
rust-lang/cargo#5387 (comment)

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants