-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Hashed dependencies of metadata into the metadata of a lib #4469
Changes from all commits
46a5fe9
69e0d9f
7336e32
d2ca374
67b3b44
f90d21f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1465,3 +1465,96 @@ Caused by: | |
")); | ||
} | ||
|
||
/// This is a freshness test for feature use with workspaces | ||
/// | ||
/// feat_lib is used by caller1 and caller2, but with different features enabled. | ||
/// This test ensures that alternating building caller1, caller2 doesn't force | ||
/// recompile of feat_lib. | ||
/// | ||
/// Ideally once we solve https://github.com/rust-lang/cargo/issues/3620, then | ||
/// a single cargo build at the top level will be enough. | ||
#[test] | ||
fn dep_used_with_separate_features() { | ||
let p = project("foo") | ||
.file("Cargo.toml", r#" | ||
[workspace] | ||
members = ["feat_lib", "caller1", "caller2"] | ||
"#) | ||
.file("feat_lib/Cargo.toml", r#" | ||
[project] | ||
name = "feat_lib" | ||
version = "0.1.0" | ||
authors = [] | ||
|
||
[features] | ||
myfeature = [] | ||
"#) | ||
.file("feat_lib/src/lib.rs", "") | ||
.file("caller1/Cargo.toml", r#" | ||
[project] | ||
name = "caller1" | ||
version = "0.1.0" | ||
authors = [] | ||
|
||
[dependencies] | ||
feat_lib = { path = "../feat_lib" } | ||
"#) | ||
.file("caller1/src/main.rs", "fn main() {}") | ||
.file("caller1/src/lib.rs", "") | ||
.file("caller2/Cargo.toml", r#" | ||
[project] | ||
name = "caller2" | ||
version = "0.1.0" | ||
authors = [] | ||
|
||
[dependencies] | ||
feat_lib = { path = "../feat_lib", features = ["myfeature"] } | ||
caller1 = { path = "../caller1" } | ||
"#) | ||
.file("caller2/src/main.rs", "fn main() {}") | ||
.file("caller2/src/lib.rs", ""); | ||
p.build(); | ||
|
||
// Build the entire workspace | ||
assert_that(p.cargo("build").arg("--all"), | ||
execs().with_status(0) | ||
.with_stderr("\ | ||
[..]Compiling feat_lib v0.1.0 ([..]) | ||
[..]Compiling caller1 v0.1.0 ([..]) | ||
[..]Compiling caller2 v0.1.0 ([..]) | ||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] | ||
")); | ||
assert_that(&p.bin("caller1"), existing_file()); | ||
assert_that(&p.bin("caller2"), existing_file()); | ||
|
||
|
||
// Build caller1. should build the dep library. Because the features | ||
// are different than the full workspace, it rebuilds. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be beautiful if building the entire workspace simply covered this, but it doesn't as is. According to #3620, this is difficult to fix? I couldn't find an easy way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just left this comment which I think is related to this. I do believe it'll be a relatively invasive fix to fix this. |
||
// Ideally once we solve https://github.com/rust-lang/cargo/issues/3620, then | ||
// a single cargo build at the top level will be enough. | ||
assert_that(p.cargo("build").cwd(p.root().join("caller1")), | ||
execs().with_status(0) | ||
.with_stderr("\ | ||
[..]Compiling feat_lib v0.1.0 ([..]) | ||
[..]Compiling caller1 v0.1.0 ([..]) | ||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] | ||
")); | ||
|
||
// Alternate building caller2/caller1 a few times, just to make sure | ||
// features are being built separately. Should not rebuild anything | ||
assert_that(p.cargo("build").cwd(p.root().join("caller2")), | ||
execs().with_status(0) | ||
.with_stderr("\ | ||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] | ||
")); | ||
assert_that(p.cargo("build").cwd(p.root().join("caller1")), | ||
execs().with_status(0) | ||
.with_stderr("\ | ||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] | ||
")); | ||
assert_that(p.cargo("build").cwd(p.root().join("caller2")), | ||
execs().with_status(0) | ||
.with_stderr("\ | ||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] | ||
")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've always mixed in features for the package itself. Just not for the deps. See this line