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

profile.dev/profile.test confusion #4438

Closed
rukai opened this issue Aug 27, 2017 · 3 comments · Fixed by #7733
Closed

profile.dev/profile.test confusion #4438

rukai opened this issue Aug 27, 2017 · 3 comments · Fixed by #7733
Labels
A-documenting-cargo-itself Area: Cargo's documentation A-profiles Area: profiles C-bug Category: bug

Comments

@rukai
Copy link
Contributor

rukai commented Aug 27, 2017

This issue applies to #[test] in libraries but not #[test] in binaries.
It also applies to tests in tests/ directory for both libraries and binaries.

When I run cargo test in one of the above cases the tests are compiled seperately to the main project.
The project uses profile.dev and the tests use profile.test

With the following cargo.toml:

[profile.dev]
opt-level = 2

[profile.test]
opt-level = 0

cargo test -v outputs the following

     Running `rustc --crate-name foo lib.rs --emit=dep-info,link -C debuginfo=2 --test -C metadata=d98c9b07f6fdda49 -C extra-filename=-d98c9b07f6fdda49 --out-dir /home/rubic/Foo/foo/target/debug/deps -L dependency=/home/rubic/Foo/foo/target/debug/deps -Zincremental=/home/rubic/Foo/foo/target/debug/incremental`
     Running `rustc --crate-name foo lib.rs --crate-type lib --emit=dep-info,link -C opt-level=2 -C debuginfo=2 -C debug-assertions=on -C metadata=cdf7b1bd72ef34ae -C extra-filename=-cdf7b1bd72ef34ae --out-dir /home/rubic/Foo/foo/target/debug/deps -L dependency=/home/rubic/Foo/foo/target/debug/deps -Zincremental=/home/rubic/Foo/foo/target/debug/incremental`

My reading of http://doc.crates.io/manifest.html had led me to assume that ALL compilation that occurs with cargo test would use profile.test
The current functionality seems to be intended. So maybe just a change to the documentation to make that more obvious would be useful.

The reason this was an issue for me was because I set [profile.dev] opt-level=2 without realizing it would cause my unittests to time out on travis. (Followed by hours of fiddling and research)

@carols10cents carols10cents added A-documenting-cargo-itself Area: Cargo's documentation A-profiles Area: profiles C-bug Category: bug labels Aug 27, 2017
@alexcrichton
Copy link
Member

cc @matklad

Yeah this is unfortunately working as intended today, it's just not working great to begin with :(. Definitely confusing!

@dwijnand
Copy link
Member

I feel like this topic is brought up often. Doesn't this duplicate existing tickets? cc @ehuss

@ehuss
Copy link
Contributor

ehuss commented Jan 14, 2019

I don't think there are any other tickets that capture exactly what this is conveying. In the new documentation, I attempted to explain profile selection a little more, such as here, but it's still not terribly clear. And the "profiles" section in manifest.md should be expanded with a clarification on how it works.

I'm often a little wary of making manifest.md even longer, since it's already quite long. What do you think about breaking it up a little? Maybe add dedicated pages for "profiles", "features", and "workspaces"? Maybe even a dedicated page describing targets (lib/bins/examples/tests/benches) and their configuration?

It's tricky with documentation to hit a good balance between concise and complete. I like the brevity of the current way the profiles are shown as a toml document. But some of the options definitely need expanding. And when profile overrides lands, it will only get longer.

ehuss added a commit to ehuss/cargo that referenced this issue Dec 21, 2019
bors added a commit that referenced this issue Dec 22, 2019
Various doc updates

This is a collection of documentation updates that have been in my todo list for a while. Each change is in a separate commit.

The "features" chapter will probably get significant changes in the future, as it is pretty bare right now. Similarly the "workspace" chapter could probably use more examples.

Closes #3062
Closes #3817
Closes #3971
Closes #4212
Closes #4438
Closes #4756
Closes #5822
Closes #6913
Closes #7055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation A-profiles Area: profiles C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants