2019-11-25 02:42:45 +00:00
|
|
|
|
//! Tests for workspaces.
|
|
|
|
|
|
2019-09-12 17:14:29 +00:00
|
|
|
|
use cargo_test_support::registry::Package;
|
2020-04-17 04:10:11 +00:00
|
|
|
|
use cargo_test_support::{basic_lib_manifest, basic_manifest, git, project, sleep_ms};
|
|
|
|
|
use std::env;
|
|
|
|
|
use std::fs;
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn simple_explicit() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = ".."
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("build").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(!p.bin("bar").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("bar").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(p.bin("bar").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.root().join("Cargo.lock").is_file());
|
|
|
|
|
assert!(!p.root().join("bar/Cargo.lock").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-11-23 15:25:12 +00:00
|
|
|
|
fn simple_explicit_default_members() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-11-23 15:25:12 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
default-members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = ".."
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-11-23 15:25:12 +00:00
|
|
|
|
let p = p.build();
|
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("build").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("bar").is_file());
|
|
|
|
|
assert!(!p.bin("foo").is_file());
|
2017-11-23 15:25:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-16 14:30:41 +00:00
|
|
|
|
#[cargo_test]
|
|
|
|
|
fn non_virtual_default_members_build_other_member() {
|
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2019-03-16 14:30:41 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = [".", "bar", "baz"]
|
|
|
|
|
default-members = ["baz"]
|
|
|
|
|
"#,
|
2019-03-16 14:30:41 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
|
|
|
|
.file("bar/src/lib.rs", "pub fn bar() {}")
|
|
|
|
|
.file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
|
|
|
|
.file("baz/src/lib.rs", "pub fn baz() {}")
|
|
|
|
|
.build();
|
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2019-03-16 14:30:41 +00:00
|
|
|
|
.with_stderr(
|
2023-02-16 03:14:51 +00:00
|
|
|
|
"[CHECKING] baz v0.1.0 ([..])\n\
|
2019-03-16 14:30:41 +00:00
|
|
|
|
[..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n",
|
|
|
|
|
)
|
|
|
|
|
.run();
|
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check --manifest-path bar/Cargo.toml")
|
2019-03-16 14:30:41 +00:00
|
|
|
|
.with_stderr(
|
2023-02-16 03:14:51 +00:00
|
|
|
|
"[CHECKING] bar v0.1.0 ([..])\n\
|
2019-03-16 14:30:41 +00:00
|
|
|
|
[..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n",
|
|
|
|
|
)
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-23 16:46:35 +00:00
|
|
|
|
#[cargo_test]
|
|
|
|
|
fn non_virtual_default_members_build_root_project() {
|
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2022-06-23 16:46:35 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
default-members = ["."]
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
|
|
|
|
.file("bar/src/lib.rs", "pub fn bar() {}")
|
|
|
|
|
.build();
|
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2022-06-23 16:46:35 +00:00
|
|
|
|
.with_stderr(
|
2023-02-16 03:14:51 +00:00
|
|
|
|
"[CHECKING] foo v0.1.0 ([..])\n\
|
2022-06-23 16:46:35 +00:00
|
|
|
|
[..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n",
|
|
|
|
|
)
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn inferred_root() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("build").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(!p.bin("bar").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("bar").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(p.bin("bar").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.root().join("Cargo.lock").is_file());
|
|
|
|
|
assert!(!p.root().join("bar/Cargo.lock").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn inferred_path_dep() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "bar" }
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("bar/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("build").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(!p.bin("bar").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("bar").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(p.bin("bar").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.root().join("Cargo.lock").is_file());
|
|
|
|
|
assert!(!p.root().join("bar/Cargo.lock").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn transitive_path_dep() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "bar" }
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
baz = { path = "../baz" }
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/lib.rs", "")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("baz/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("baz/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("build").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(!p.bin("bar").is_file());
|
|
|
|
|
assert!(!p.bin("baz").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("bar").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(p.bin("bar").is_file());
|
|
|
|
|
assert!(!p.bin("baz").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("baz").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(p.bin("bar").is_file());
|
|
|
|
|
assert!(p.bin("baz").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.root().join("Cargo.lock").is_file());
|
|
|
|
|
assert!(!p.root().join("bar/Cargo.lock").is_file());
|
|
|
|
|
assert!(!p.root().join("baz/Cargo.lock").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn parent_pointer_works() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "../bar" }
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("foo/src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../foo"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("foo").run();
|
|
|
|
|
p.cargo("build").cwd("bar").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.root().join("foo/Cargo.lock").is_file());
|
|
|
|
|
assert!(!p.root().join("bar/Cargo.lock").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn same_names_in_workspace() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = ".."
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: two packages named `foo` in this workspace:
|
|
|
|
|
- [..]Cargo.toml
|
|
|
|
|
- [..]Cargo.toml
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn parent_doesnt_point_to_child() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2019-03-20 23:34:56 +00:00
|
|
|
|
.cwd("bar")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: current package believes it's in a workspace when it's not:
|
|
|
|
|
current: [..]Cargo.toml
|
|
|
|
|
workspace: [..]Cargo.toml
|
|
|
|
|
|
|
|
|
|
this may be fixable [..]
|
2019-04-01 00:48:15 +00:00
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn invalid_parent_pointer() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "foo"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: failed to read `[..]Cargo.toml`
|
|
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn invalid_members() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2021-04-17 05:56:39 +00:00
|
|
|
|
[ERROR] failed to load manifest for workspace member `[..]/foo`
|
|
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
|
failed to read `[..]foo/foo/Cargo.toml`
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn bare_workspace_ok() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn two_roots() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = [".."]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: multiple workspace roots found in the same workspace:
|
|
|
|
|
[..]
|
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn workspace_isnt_root() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "bar"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr("error: root of a workspace inferred but wasn't a root: [..]")
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn dangling_member() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../baz"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"baz/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "baz"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../baz"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("baz/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: package `[..]` is a member of the wrong workspace
|
|
|
|
|
expected: [..]
|
|
|
|
|
actual: [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn cycle() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "bar"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = ".."
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-12-29 01:47:50 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
|
|
|
|
"[ERROR] root of a workspace inferred but wasn't a root: [..]/foo/bar/Cargo.toml",
|
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn share_dependencies() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
dep1 = "0.1"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
dep1 = "< 0.1.5"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
Package::new("dep1", "0.1.3").publish();
|
|
|
|
|
Package::new("dep1", "0.1.8").publish();
|
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
|
[UPDATING] `[..]` index
|
2018-09-14 20:33:18 +00:00
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
|
[DOWNLOADED] dep1 v0.1.3 ([..])
|
2023-02-16 03:14:51 +00:00
|
|
|
|
[CHECKING] dep1 v0.1.3
|
|
|
|
|
[CHECKING] foo v0.1.0 ([..])
|
2017-01-12 01:03:36 +00:00
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn fetch_fetches_all() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
dep1 = "*"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
Package::new("dep1", "0.1.3").publish();
|
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("fetch")
|
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
|
[UPDATING] `[..]` index
|
2018-09-14 20:33:18 +00:00
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
|
[DOWNLOADED] dep1 v0.1.3 ([..])
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn lock_works_for_everyone() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
dep2 = "0.1"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
dep1 = "0.1"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
Package::new("dep1", "0.1.0").publish();
|
|
|
|
|
Package::new("dep2", "0.1.0").publish();
|
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("generate-lockfile")
|
2018-09-08 09:23:57 +00:00
|
|
|
|
.with_stderr("[UPDATING] `[..]` index")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
Package::new("dep1", "0.1.1").publish();
|
|
|
|
|
Package::new("dep2", "0.1.1").publish();
|
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2018-09-14 20:33:18 +00:00
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
|
[DOWNLOADED] dep2 v0.1.0 ([..])
|
2023-02-16 03:14:51 +00:00
|
|
|
|
[CHECKING] dep2 v0.1.0
|
|
|
|
|
[CHECKING] foo v0.1.0 ([..])
|
2017-01-12 01:03:36 +00:00
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2019-03-20 23:34:56 +00:00
|
|
|
|
.cwd("bar")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2018-09-14 20:33:18 +00:00
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
|
[DOWNLOADED] dep1 v0.1.0 ([..])
|
2023-02-16 03:14:51 +00:00
|
|
|
|
[CHECKING] dep1 v0.1.0
|
|
|
|
|
[CHECKING] bar v0.1.0 ([..])
|
2017-01-12 01:03:36 +00:00
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn virtual_works() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("bar").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.root().join("Cargo.lock").is_file());
|
|
|
|
|
assert!(p.bin("bar").is_file());
|
|
|
|
|
assert!(!p.root().join("bar/Cargo.lock").is_file());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-12-12 12:57:19 +00:00
|
|
|
|
fn explicit_package_argument_works_with_virtual_manifest() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2016-12-12 12:57:19 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2018-09-06 00:12:53 +00:00
|
|
|
|
p.cargo("build --package bar").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.root().join("Cargo.lock").is_file());
|
|
|
|
|
assert!(p.bin("bar").is_file());
|
|
|
|
|
assert!(!p.root().join("bar/Cargo.lock").is_file());
|
2016-12-12 12:57:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn virtual_misconfigure() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2019-03-20 23:34:56 +00:00
|
|
|
|
.cwd("bar")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: current package believes it's in a workspace when it's not:
|
2018-09-08 02:42:26 +00:00
|
|
|
|
current: [CWD]/Cargo.toml
|
2016-05-15 00:14:24 +00:00
|
|
|
|
workspace: [..]Cargo.toml
|
|
|
|
|
|
|
|
|
|
this may be fixable by adding `bar` to the `workspace.members` array of the \
|
|
|
|
|
manifest located at: [..]
|
2019-04-01 00:48:15 +00:00
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-05-26 21:00:45 +00:00
|
|
|
|
fn virtual_build_all_implied() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2016-10-21 03:57:51 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").run();
|
2016-10-21 03:57:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-11-23 15:01:29 +00:00
|
|
|
|
fn virtual_default_members() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar", "baz"]
|
|
|
|
|
default-members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
2017-11-23 15:01:29 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("baz/src/main.rs", "fn main() {}");
|
|
|
|
|
let p = p.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("build").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("bar").is_file());
|
|
|
|
|
assert!(!p.bin("baz").is_file());
|
2017-11-23 15:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-11-23 15:01:29 +00:00
|
|
|
|
fn virtual_default_member_is_not_a_member() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
default-members = ["something-else"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2017-11-23 15:01:29 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
|
|
|
|
let p = p.build();
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2017-11-23 15:01:29 +00:00
|
|
|
|
error: package `[..]something-else` is listed in workspace’s default-members \
|
|
|
|
|
but is not a member.
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2017-11-23 15:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-16 14:30:41 +00:00
|
|
|
|
#[cargo_test]
|
|
|
|
|
fn virtual_default_members_build_other_member() {
|
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar", "baz"]
|
|
|
|
|
default-members = ["baz"]
|
|
|
|
|
"#,
|
2019-03-16 14:30:41 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
|
|
|
|
.file("bar/src/lib.rs", "pub fn bar() {}")
|
|
|
|
|
.file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
|
|
|
|
.file("baz/src/lib.rs", "pub fn baz() {}")
|
|
|
|
|
.build();
|
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check --manifest-path bar/Cargo.toml")
|
2019-03-16 14:30:41 +00:00
|
|
|
|
.with_stderr(
|
2023-02-16 03:14:51 +00:00
|
|
|
|
"[CHECKING] bar v0.1.0 ([..])\n\
|
2019-03-16 14:30:41 +00:00
|
|
|
|
[..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n",
|
|
|
|
|
)
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-10-21 03:57:51 +00:00
|
|
|
|
fn virtual_build_no_members() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project().file(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
);
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2017-09-14 11:52:06 +00:00
|
|
|
|
error: manifest path `[..]` contains no package: The manifest is virtual, \
|
|
|
|
|
and the workspace has no members.
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn include_virtual() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
|
);
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: multiple workspace roots found in the same workspace:
|
|
|
|
|
[..]
|
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
fn members_include_path_deps() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["p1"]
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
p3 = { path = "p3" }
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"p1/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "p1"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
p2 = { path = "../p2" }
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("p1/src/lib.rs", "")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("p2/Cargo.toml", &basic_manifest("p2", "0.1.0"))
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("p2/src/lib.rs", "")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("p3/Cargo.toml", &basic_manifest("p3", "0.1.0"))
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("p3/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("p1").run();
|
|
|
|
|
p.cargo("check").cwd("p2").run();
|
|
|
|
|
p.cargo("check").cwd("p3").run();
|
|
|
|
|
p.cargo("check").run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(p.root().join("target").is_dir());
|
|
|
|
|
assert!(!p.root().join("p1/target").is_dir());
|
|
|
|
|
assert!(!p.root().join("p2/target").is_dir());
|
|
|
|
|
assert!(!p.root().join("p3/target").is_dir());
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2023-10-28 14:31:47 +00:00
|
|
|
|
fn new_creates_members_list() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("new --lib bar")
|
2024-01-29 21:38:04 +00:00
|
|
|
|
.with_stderr("\
|
|
|
|
|
[CREATING] library `bar` package
|
|
|
|
|
[NOTE] see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
|
|
|
")
|
2018-12-08 11:19:47 +00:00
|
|
|
|
.run();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2019-04-11 19:29:21 +00:00
|
|
|
|
fn new_warning_with_corrupt_ws() {
|
|
|
|
|
let p = project().file("Cargo.toml", "asdf").build();
|
|
|
|
|
p.cargo("new bar")
|
|
|
|
|
.with_stderr(
|
|
|
|
|
"\
|
2024-01-29 21:29:10 +00:00
|
|
|
|
[CREATING] binary (application) `bar` package
|
2023-12-14 22:28:05 +00:00
|
|
|
|
[ERROR] expected `.`, `=`
|
|
|
|
|
--> Cargo.toml:1:5
|
|
|
|
|
|
|
|
|
|
|
1 | asdf
|
|
|
|
|
| ^
|
|
|
|
|
|
|
2021-01-24 19:05:11 +00:00
|
|
|
|
[WARNING] compiling this new package may not work due to invalid workspace configuration
|
2019-04-11 19:29:21 +00:00
|
|
|
|
|
2024-01-29 21:38:04 +00:00
|
|
|
|
[NOTE] see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
2019-04-11 19:29:21 +00:00
|
|
|
|
",
|
|
|
|
|
)
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-07-08 06:11:22 +00:00
|
|
|
|
fn lock_doesnt_change_depending_on_crate() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ['baz']
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
foo = "*"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"baz/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "baz"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
bar = "*"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("baz/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
|
|
|
|
Package::new("foo", "1.0.0").publish();
|
|
|
|
|
Package::new("bar", "1.0.0").publish();
|
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").run();
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
2020-04-17 04:10:11 +00:00
|
|
|
|
let lockfile = p.read_lockfile();
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("baz").run();
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
2020-04-17 04:10:11 +00:00
|
|
|
|
let lockfile2 = p.read_lockfile();
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
|
|
|
|
assert_eq!(lockfile, lockfile2);
|
|
|
|
|
}
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
fn rebuild_please() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ['lib', 'bin']
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("lib/Cargo.toml", &basic_manifest("lib", "0.1.0"))
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"lib/src/lib.rs",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
pub fn foo() -> u32 { 0 }
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"bin/Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "bin"
|
|
|
|
|
version = "0.1.0"
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
lib = { path = "../lib" }
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"bin/src/main.rs",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
extern crate lib;
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
fn main() {
|
|
|
|
|
assert_eq!(lib::foo(), 0);
|
|
|
|
|
}
|
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
|
);
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("run").cwd("bin").run();
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
|
2016-07-28 17:26:32 +00:00
|
|
|
|
sleep_ms(1000);
|
|
|
|
|
|
2020-04-17 04:10:11 +00:00
|
|
|
|
p.change_file("lib/src/lib.rs", "pub fn foo() -> u32 { 1 }");
|
2018-03-14 15:17:44 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("lib").run();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("run")
|
2019-03-20 23:34:56 +00:00
|
|
|
|
.cwd("bin")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
2018-12-29 01:47:50 +00:00
|
|
|
|
.with_stderr_contains("[..]assertion[..]")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.run();
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
}
|
2016-07-31 23:35:52 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-07-31 23:35:52 +00:00
|
|
|
|
fn workspace_in_git() {
|
|
|
|
|
let git_project = git::new("dep1", |project| {
|
|
|
|
|
project
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
2016-07-31 23:35:52 +00:00
|
|
|
|
.file("foo/src/lib.rs", "")
|
2019-08-13 05:25:36 +00:00
|
|
|
|
});
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
&format!(
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "lib"
|
|
|
|
|
version = "0.1.0"
|
2016-07-31 23:35:52 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies.foo]
|
|
|
|
|
git = '{}'
|
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
|
git_project.url()
|
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"src/lib.rs",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
pub fn foo() -> u32 { 0 }
|
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
|
);
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-07-31 23:35:52 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").run();
|
2016-07-31 23:35:52 +00:00
|
|
|
|
}
|
2016-08-25 10:10:45 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2022-05-10 21:47:28 +00:00
|
|
|
|
fn lockfile_can_specify_nonexistent_members() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["a"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("a/Cargo.toml", &basic_manifest("a", "0.1.0"))
|
2016-08-25 10:10:45 +00:00
|
|
|
|
.file("a/src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.lock",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[[package]]
|
|
|
|
|
name = "a"
|
|
|
|
|
version = "0.1.0"
|
2016-08-25 10:10:45 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[[package]]
|
|
|
|
|
name = "b"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
|
);
|
2016-08-25 10:10:45 +00:00
|
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-08-25 10:10:45 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("a").run();
|
2016-08-25 10:10:45 +00:00
|
|
|
|
}
|
2016-09-14 19:02:47 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-09-14 19:02:47 +00:00
|
|
|
|
fn you_cannot_generate_lockfile_for_empty_workspaces() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
2016-09-14 19:02:47 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-09-14 19:02:47 +00:00
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("update")
|
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr("error: you can't generate a lockfile for an empty workspace.")
|
|
|
|
|
.run();
|
2016-09-14 19:02:47 +00:00
|
|
|
|
}
|
2016-09-26 21:13:49 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-09-26 21:13:49 +00:00
|
|
|
|
fn workspace_with_transitive_dev_deps() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.5.0"
|
|
|
|
|
authors = ["mbrubeck@example.com"]
|
2016-09-26 21:13:49 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies.bar]
|
|
|
|
|
path = "bar"
|
2016-09-26 21:13:49 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", r#"fn main() {}"#)
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.5.0"
|
|
|
|
|
authors = ["mbrubeck@example.com"]
|
2016-09-26 21:13:49 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dev-dependencies.baz]
|
|
|
|
|
path = "../baz"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"bar/src/lib.rs",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
pub fn init() {}
|
2016-09-26 21:13:49 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
#[cfg(test)]
|
2016-09-26 21:13:49 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn test() {
|
|
|
|
|
extern crate baz;
|
|
|
|
|
baz::do_stuff();
|
|
|
|
|
}
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("baz/Cargo.toml", &basic_manifest("baz", "0.5.0"))
|
2016-09-26 21:13:49 +00:00
|
|
|
|
.file("baz/src/lib.rs", r#"pub fn do_stuff() {}"#);
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-09-26 21:13:49 +00:00
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("test -p bar").run();
|
2016-09-26 21:13:49 +00:00
|
|
|
|
}
|
2016-12-15 17:27:48 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-12-15 17:27:48 +00:00
|
|
|
|
fn error_if_parent_cargo_toml_is_invalid() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2016-12-15 17:27:48 +00:00
|
|
|
|
.file("Cargo.toml", "Totally not a TOML file")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2016-12-15 17:27:48 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-12-15 17:27:48 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2019-03-20 23:34:56 +00:00
|
|
|
|
.cwd("bar")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
2023-12-14 22:28:05 +00:00
|
|
|
|
.with_stderr(
|
|
|
|
|
"\
|
|
|
|
|
[ERROR] expected `.`, `=`
|
|
|
|
|
--> ../Cargo.toml:1:9
|
|
|
|
|
|
|
|
|
|
|
1 | Totally not a TOML file
|
|
|
|
|
| ^
|
|
|
|
|
|
|
|
|
|
|
",
|
|
|
|
|
)
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.run();
|
2016-12-15 17:27:48 +00:00
|
|
|
|
}
|
2017-01-03 11:11:57 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-01-03 11:11:57 +00:00
|
|
|
|
fn relative_path_for_member_works() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-01-03 11:11:57 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["../bar"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("foo/src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../foo"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-01-03 11:11:57 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("foo").run();
|
|
|
|
|
p.cargo("check").cwd("bar").run();
|
2016-12-22 17:56:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-02-14 20:04:24 +00:00
|
|
|
|
fn relative_path_for_root_works() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-02-14 20:04:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
2017-02-14 20:04:24 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
subproj = { path = "./subproj" }
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("subproj/Cargo.toml", &basic_manifest("subproj", "0.1.0"))
|
2017-02-14 20:04:24 +00:00
|
|
|
|
.file("subproj/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-02-14 20:04:24 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check --manifest-path ./Cargo.toml").run();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check --manifest-path ../Cargo.toml")
|
2019-03-20 23:34:56 +00:00
|
|
|
|
.cwd("subproj")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.run();
|
2017-02-14 20:04:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2016-12-22 17:56:40 +00:00
|
|
|
|
fn path_dep_outside_workspace_is_not_member() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-07-24 12:59:42 +00:00
|
|
|
|
.no_manifest()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"ws/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "ws"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2016-12-22 17:56:40 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
foo = { path = "../foo" }
|
2016-12-22 17:56:40 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
2020-09-27 00:59:58 +00:00
|
|
|
|
.file("ws/src/lib.rs", "extern crate foo;")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
2016-12-22 17:56:40 +00:00
|
|
|
|
.file("foo/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-12-22 17:56:40 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("ws").run();
|
2017-01-14 22:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-01-14 22:14:47 +00:00
|
|
|
|
fn test_in_and_out_of_workspace() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-07-24 12:59:42 +00:00
|
|
|
|
.no_manifest()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"ws/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "ws"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
foo = { path = "../foo" }
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = [ "../bar" ]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
2020-09-27 00:59:58 +00:00
|
|
|
|
.file("ws/src/lib.rs", "extern crate foo; pub fn f() { foo::f() }")
|
2018-12-08 11:19:47 +00:00
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "../bar" }
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file(
|
2018-08-28 09:20:03 +00:00
|
|
|
|
"foo/src/lib.rs",
|
|
|
|
|
"extern crate bar; pub fn f() { bar::f() }",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
workspace = "../ws"
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("bar/src/lib.rs", "pub fn f() { }");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("ws").run();
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.root().join("ws/Cargo.lock").is_file());
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(p.root().join("ws/target").is_dir());
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(!p.root().join("foo/Cargo.lock").is_file());
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(!p.root().join("foo/target").is_dir());
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(!p.root().join("bar/Cargo.lock").is_file());
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(!p.root().join("bar/target").is_dir());
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("foo").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.root().join("foo/Cargo.lock").is_file());
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(p.root().join("foo/target").is_dir());
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(!p.root().join("bar/Cargo.lock").is_file());
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(!p.root().join("bar/target").is_dir());
|
2017-01-14 22:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-01-14 22:14:47 +00:00
|
|
|
|
fn test_path_dependency_under_member() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"ws/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "ws"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
foo = { path = "../foo" }
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
2020-09-27 00:59:58 +00:00
|
|
|
|
.file("ws/src/lib.rs", "extern crate foo; pub fn f() { foo::f() }")
|
2018-12-08 11:19:47 +00:00
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
workspace = "../ws"
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "./bar" }
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file(
|
2018-08-28 09:20:03 +00:00
|
|
|
|
"foo/src/lib.rs",
|
|
|
|
|
"extern crate bar; pub fn f() { bar::f() }",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("foo/bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2017-01-14 22:14:47 +00:00
|
|
|
|
.file("foo/bar/src/lib.rs", "pub fn f() { }");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("ws").run();
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(!p.root().join("foo/bar/Cargo.lock").is_file());
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(!p.root().join("foo/bar/target").is_dir());
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("foo/bar").run();
|
2017-01-16 22:30:59 +00:00
|
|
|
|
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(!p.root().join("foo/bar/Cargo.lock").is_file());
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(!p.root().join("foo/bar/target").is_dir());
|
2017-01-14 22:14:47 +00:00
|
|
|
|
}
|
2017-03-16 21:50:23 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-03-16 21:50:23 +00:00
|
|
|
|
fn excluded_simple() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "ws"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-03-16 21:50:23 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
exclude = ["foo"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/lib.rs", "")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("foo/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-03-16 21:50:23 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").run();
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(p.root().join("target").is_dir());
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("foo").run();
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(p.root().join("foo/target").is_dir());
|
2017-03-16 21:50:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-03-16 21:50:23 +00:00
|
|
|
|
fn exclude_members_preferred() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "ws"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-03-16 21:50:23 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo/bar"]
|
|
|
|
|
exclude = ["foo"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/lib.rs", "")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("foo/src/lib.rs", "")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("foo/bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("foo/bar/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-03-16 21:50:23 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").run();
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(p.root().join("target").is_dir());
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("foo").run();
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(p.root().join("foo/target").is_dir());
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("foo/bar").run();
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(!p.root().join("foo/bar/target").is_dir());
|
2017-03-16 21:50:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-03-16 21:50:23 +00:00
|
|
|
|
fn exclude_but_also_depend() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "ws"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-03-16 21:50:23 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "foo/bar" }
|
2017-03-16 21:50:23 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
exclude = ["foo"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/lib.rs", "")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("foo/src/lib.rs", "")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("foo/bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("foo/bar/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-03-16 21:50:23 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").run();
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(p.root().join("target").is_dir());
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("foo").run();
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(p.root().join("foo/target").is_dir());
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").cwd("foo/bar").run();
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(p.root().join("foo/bar/target").is_dir());
|
2017-03-16 21:50:23 +00:00
|
|
|
|
}
|
2017-04-29 02:08:07 +00:00
|
|
|
|
|
2020-07-14 20:58:15 +00:00
|
|
|
|
#[cargo_test]
|
|
|
|
|
fn excluded_default_members_still_must_be_members() {
|
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo"]
|
|
|
|
|
default-members = ["foo", "bar"]
|
|
|
|
|
exclude = ["bar"]
|
|
|
|
|
"#,
|
2020-07-14 20:58:15 +00:00
|
|
|
|
)
|
|
|
|
|
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
|
|
|
|
.file("foo/src/lib.rs", "")
|
|
|
|
|
.file("bar/something.txt", "");
|
|
|
|
|
let p = p.build();
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2020-07-14 20:58:15 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
|
|
|
|
"\
|
|
|
|
|
error: package `[..]bar` is listed in workspace’s default-members \
|
|
|
|
|
but is not a member.
|
|
|
|
|
",
|
|
|
|
|
)
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
|
fn excluded_default_members_crate_glob() {
|
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo", "bar/*"]
|
|
|
|
|
default-members = ["bar/*"]
|
|
|
|
|
exclude = ["bar/quux"]
|
|
|
|
|
"#,
|
2020-07-14 20:58:15 +00:00
|
|
|
|
)
|
|
|
|
|
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
|
|
|
|
.file("foo/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("bar/baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
|
|
|
|
.file("bar/baz/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("bar/quux/Cargo.toml", &basic_manifest("quux", "0.1.0"))
|
2020-07-20 16:38:20 +00:00
|
|
|
|
.file("bar/quux/src/main.rs", "fn main() {}");
|
2020-07-14 20:58:15 +00:00
|
|
|
|
|
|
|
|
|
let p = p.build();
|
|
|
|
|
p.cargo("build").run();
|
|
|
|
|
|
|
|
|
|
assert!(p.root().join("target").is_dir());
|
|
|
|
|
assert!(!p.bin("foo").is_file());
|
|
|
|
|
assert!(p.bin("baz").is_file());
|
2020-07-20 16:38:20 +00:00
|
|
|
|
assert!(!p.bin("quux").exists());
|
2020-07-14 20:58:15 +00:00
|
|
|
|
|
|
|
|
|
p.cargo("build --workspace").run();
|
|
|
|
|
assert!(p.root().join("target").is_dir());
|
|
|
|
|
assert!(p.bin("foo").is_file());
|
2020-07-20 16:38:20 +00:00
|
|
|
|
assert!(!p.bin("quux").exists());
|
2020-07-14 20:58:15 +00:00
|
|
|
|
|
|
|
|
|
p.cargo("build").cwd("bar/quux").run();
|
|
|
|
|
assert!(p.root().join("bar/quux/target").is_dir());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
|
fn excluded_default_members_not_crate_glob() {
|
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo", "bar/*"]
|
|
|
|
|
default-members = ["bar/*"]
|
|
|
|
|
exclude = ["bar/docs"]
|
|
|
|
|
"#,
|
2020-07-14 20:58:15 +00:00
|
|
|
|
)
|
|
|
|
|
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
|
|
|
|
.file("foo/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("bar/baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
|
|
|
|
.file("bar/baz/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("bar/docs/readme.txt", "This folder is not a crate!");
|
|
|
|
|
|
|
|
|
|
let p = p.build();
|
|
|
|
|
p.cargo("build").run();
|
|
|
|
|
|
|
|
|
|
assert!(!p.bin("foo").is_file());
|
|
|
|
|
assert!(p.bin("baz").is_file());
|
|
|
|
|
p.cargo("build --workspace").run();
|
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-04-29 02:08:07 +00:00
|
|
|
|
fn glob_syntax() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-12-08 11:19:47 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-04-29 02:08:07 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["crates/*"]
|
|
|
|
|
exclude = ["crates/qux"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
2017-04-29 02:08:07 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-12-08 11:19:47 +00:00
|
|
|
|
.file(
|
|
|
|
|
"crates/bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../.."
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
2017-04-29 02:08:07 +00:00
|
|
|
|
.file("crates/bar/src/main.rs", "fn main() {}")
|
2018-12-08 11:19:47 +00:00
|
|
|
|
.file(
|
|
|
|
|
"crates/baz/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "baz"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../.."
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
2017-04-29 02:08:07 +00:00
|
|
|
|
.file("crates/baz/src/main.rs", "fn main() {}")
|
2018-12-08 11:19:47 +00:00
|
|
|
|
.file(
|
|
|
|
|
"crates/qux/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "qux"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
2017-04-29 02:08:07 +00:00
|
|
|
|
.file("crates/qux/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-04-29 02:08:07 +00:00
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("build").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(!p.bin("bar").is_file());
|
|
|
|
|
assert!(!p.bin("baz").is_file());
|
2017-04-29 02:08:07 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("crates/bar").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(p.bin("bar").is_file());
|
2017-04-29 02:08:07 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("crates/baz").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(p.bin("baz").is_file());
|
2017-04-29 02:08:07 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("crates/qux").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(!p.bin("qux").is_file());
|
2017-04-29 02:08:07 +00:00
|
|
|
|
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.root().join("Cargo.lock").is_file());
|
|
|
|
|
assert!(!p.root().join("crates/bar/Cargo.lock").is_file());
|
|
|
|
|
assert!(!p.root().join("crates/baz/Cargo.lock").is_file());
|
|
|
|
|
assert!(p.root().join("crates/qux/Cargo.lock").is_file());
|
2017-04-29 02:08:07 +00:00
|
|
|
|
}
|
2017-05-07 06:33:45 +00:00
|
|
|
|
|
2017-09-26 05:55:02 +00:00
|
|
|
|
/*FIXME: This fails because of how workspace.exclude and workspace.members are working.
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-09-26 05:55:02 +00:00
|
|
|
|
fn glob_syntax_2() {
|
2018-07-20 14:25:51 +00:00
|
|
|
|
let p = project()
|
2017-09-26 05:55:02 +00:00
|
|
|
|
.file("Cargo.toml", r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2017-09-26 05:55:02 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["crates/b*"]
|
|
|
|
|
exclude = ["crates/q*"]
|
|
|
|
|
"#)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
|
.file("crates/bar/Cargo.toml", r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2017-09-26 05:55:02 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../.."
|
|
|
|
|
"#)
|
|
|
|
|
.file("crates/bar/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("crates/baz/Cargo.toml", r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2017-09-26 05:55:02 +00:00
|
|
|
|
name = "baz"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../.."
|
|
|
|
|
"#)
|
|
|
|
|
.file("crates/baz/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("crates/qux/Cargo.toml", r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2017-09-26 05:55:02 +00:00
|
|
|
|
name = "qux"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
"#)
|
|
|
|
|
.file("crates/qux/src/main.rs", "fn main() {}");
|
|
|
|
|
p.build();
|
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("build").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(!p.bin("bar").is_file());
|
|
|
|
|
assert!(!p.bin("baz").is_file());
|
2017-09-26 05:55:02 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("crates/bar").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(p.bin("bar").is_file());
|
2017-09-26 05:55:02 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("crates/baz").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("foo").is_file());
|
|
|
|
|
assert!(p.bin("baz").is_file());
|
2017-09-26 05:55:02 +00:00
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("crates/qux").run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(!p.bin("qux").is_file());
|
2017-09-26 05:55:02 +00:00
|
|
|
|
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.root().join("Cargo.lock").is_file());
|
|
|
|
|
assert!(!p.root().join("crates/bar/Cargo.lock").is_file());
|
|
|
|
|
assert!(!p.root().join("crates/baz/Cargo.lock").is_file());
|
|
|
|
|
assert!(p.root().join("crates/qux/Cargo.lock").is_file());
|
2017-09-26 05:55:02 +00:00
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-05-09 05:30:23 +00:00
|
|
|
|
fn glob_syntax_invalid_members() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-12-08 11:19:47 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-05-07 06:33:45 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["crates/*"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
2017-05-07 06:33:45 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
|
.file("crates/bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-05-07 06:33:45 +00:00
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2021-04-17 05:56:39 +00:00
|
|
|
|
[ERROR] failed to load manifest for workspace member `[..]/crates/bar`
|
|
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
|
failed to read `[..]foo/crates/bar/Cargo.toml`
|
2017-05-07 06:33:45 +00:00
|
|
|
|
|
2017-05-09 05:30:23 +00:00
|
|
|
|
Caused by:
|
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2017-05-07 06:33:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 04:01:23 +00:00
|
|
|
|
/// This is a freshness test for feature use with workspaces.
|
2017-09-05 00:13:26 +00:00
|
|
|
|
///
|
2019-02-03 04:01:23 +00:00
|
|
|
|
/// `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`.
|
2017-09-05 00:13:26 +00:00
|
|
|
|
///
|
2019-02-03 04:01:23 +00:00
|
|
|
|
/// Ideally, once we solve rust-lang/cargo#3620, then a single Cargo build at the top level
|
|
|
|
|
/// will be enough.
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-09-05 00:13:26 +00:00
|
|
|
|
fn dep_used_with_separate_features() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["feat_lib", "caller1", "caller2"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"feat_lib/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "feat_lib"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-09-05 00:13:26 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[features]
|
|
|
|
|
myfeature = []
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("feat_lib/src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"caller1/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "caller1"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-09-05 00:13:26 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
feat_lib = { path = "../feat_lib" }
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("caller1/src/main.rs", "fn main() {}")
|
2017-09-05 00:13:26 +00:00
|
|
|
|
.file("caller1/src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"caller2/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
|
name = "caller2"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2017-09-05 00:13:26 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
feat_lib = { path = "../feat_lib", features = ["myfeature"] }
|
|
|
|
|
caller1 = { path = "../caller1" }
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("caller2/src/main.rs", "fn main() {}")
|
2017-09-05 00:13:26 +00:00
|
|
|
|
.file("caller2/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-09-05 00:13:26 +00:00
|
|
|
|
|
2019-02-03 04:01:23 +00:00
|
|
|
|
// Build the entire workspace.
|
2019-08-12 12:31:20 +00:00
|
|
|
|
p.cargo("build --workspace")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2017-09-05 00:13:26 +00:00
|
|
|
|
[..]Compiling feat_lib v0.1.0 ([..])
|
|
|
|
|
[..]Compiling caller1 v0.1.0 ([..])
|
|
|
|
|
[..]Compiling caller2 v0.1.0 ([..])
|
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2018-08-29 06:11:10 +00:00
|
|
|
|
assert!(p.bin("caller1").is_file());
|
|
|
|
|
assert!(p.bin("caller2").is_file());
|
2017-09-05 00:13:26 +00:00
|
|
|
|
|
2019-02-03 04:01:23 +00:00
|
|
|
|
// Build `caller1`. Should build the dep library. Because the features
|
2017-09-05 00:13:26 +00:00
|
|
|
|
// are different than the full workspace, it rebuilds.
|
2019-02-03 04:01:23 +00:00
|
|
|
|
// Ideally once we solve rust-lang/cargo#3620, then a single Cargo build at the top level
|
|
|
|
|
// will be enough.
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("build")
|
2019-03-20 23:34:56 +00:00
|
|
|
|
.cwd("caller1")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"\
|
2017-09-05 00:13:26 +00:00
|
|
|
|
[..]Compiling feat_lib v0.1.0 ([..])
|
|
|
|
|
[..]Compiling caller1 v0.1.0 ([..])
|
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
2017-09-05 00:13:26 +00:00
|
|
|
|
|
2019-02-03 04:01:23 +00:00
|
|
|
|
// Alternate building `caller2`/`caller1` a few times, just to make sure
|
|
|
|
|
// features are being built separately. Should not rebuild anything.
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("build")
|
2019-03-20 23:34:56 +00:00
|
|
|
|
.cwd("caller2")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]")
|
|
|
|
|
.run();
|
|
|
|
|
p.cargo("build")
|
2019-03-20 23:34:56 +00:00
|
|
|
|
.cwd("caller1")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]")
|
|
|
|
|
.run();
|
|
|
|
|
p.cargo("build")
|
2019-03-20 23:34:56 +00:00
|
|
|
|
.cwd("caller2")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]")
|
|
|
|
|
.run();
|
2017-09-05 00:13:26 +00:00
|
|
|
|
}
|
2017-09-26 05:55:02 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-12-01 01:32:15 +00:00
|
|
|
|
fn dont_recurse_out_of_cargo_home() {
|
|
|
|
|
let git_project = git::new("dep", |project| {
|
|
|
|
|
project
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("Cargo.toml", &basic_manifest("dep", "0.1.0"))
|
2017-12-01 01:32:15 +00:00
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"build.rs",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
use std::env;
|
|
|
|
|
use std::path::Path;
|
|
|
|
|
use std::process::{self, Command};
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
let cargo = env::var_os("CARGO").unwrap();
|
|
|
|
|
let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap();
|
|
|
|
|
let output = Command::new(cargo)
|
|
|
|
|
.args(&["metadata", "--format-version", "1", "--manifest-path"])
|
|
|
|
|
.arg(&Path::new(&cargo_manifest_dir).join("Cargo.toml"))
|
|
|
|
|
.output()
|
|
|
|
|
.unwrap();
|
|
|
|
|
if !output.status.success() {
|
|
|
|
|
eprintln!("{}", String::from_utf8(output.stderr).unwrap());
|
|
|
|
|
process::exit(1);
|
|
|
|
|
}
|
2017-12-01 01:32:15 +00:00
|
|
|
|
}
|
2020-09-27 00:59:58 +00:00
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
|
)
|
2019-08-13 05:25:36 +00:00
|
|
|
|
});
|
2018-07-20 17:41:44 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
&format!(
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
2017-12-01 01:32:15 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies.dep]
|
|
|
|
|
git = "{}"
|
2017-12-01 01:32:15 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
|
git_project.url()
|
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/lib.rs", "");
|
2017-12-01 01:32:15 +00:00
|
|
|
|
let p = p.build();
|
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
|
.env("CARGO_HOME", p.root().join(".cargo"))
|
|
|
|
|
.run();
|
2017-12-01 01:32:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 04:01:23 +00:00
|
|
|
|
// FIXME: this fails because of how workspace.exclude and workspace.members are working.
|
|
|
|
|
/*
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-09-26 05:55:02 +00:00
|
|
|
|
fn include_and_exclude() {
|
2018-07-20 14:25:51 +00:00
|
|
|
|
let p = project()
|
2017-09-26 05:55:02 +00:00
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo"]
|
|
|
|
|
exclude = ["foo/bar"]
|
|
|
|
|
"#)
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
2017-09-26 05:55:02 +00:00
|
|
|
|
.file("foo/src/lib.rs", "")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("foo/bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2017-09-26 05:55:02 +00:00
|
|
|
|
.file("foo/bar/src/lib.rs", "");
|
|
|
|
|
p.build();
|
|
|
|
|
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("foo").run();
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(p.root().join("target").is_dir());
|
|
|
|
|
assert!(!p.root().join("foo/target").is_dir());
|
2019-03-20 23:34:56 +00:00
|
|
|
|
p.cargo("build").cwd("foo/bar").run();
|
2018-08-29 05:53:01 +00:00
|
|
|
|
assert!(p.root().join("foo/bar/target").is_dir());
|
2017-09-26 05:55:02 +00:00
|
|
|
|
}
|
|
|
|
|
*/
|
2017-12-13 21:19:12 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2017-12-13 21:19:12 +00:00
|
|
|
|
fn cargo_home_at_root_works() {
|
2018-07-20 17:41:44 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
2017-12-13 21:19:12 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["a"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/lib.rs", "")
|
2018-07-24 22:35:01 +00:00
|
|
|
|
.file("a/Cargo.toml", &basic_manifest("a", "0.1.0"))
|
2017-12-13 21:19:12 +00:00
|
|
|
|
.file("a/src/lib.rs", "");
|
|
|
|
|
let p = p.build();
|
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check").run();
|
|
|
|
|
p.cargo("check --frozen").env("CARGO_HOME", p.root()).run();
|
2017-12-13 21:19:12 +00:00
|
|
|
|
}
|
2018-01-31 18:30:01 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2018-01-31 18:30:01 +00:00
|
|
|
|
fn relative_rustc() {
|
2018-07-20 17:41:44 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"src/main.rs",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
use std::process::Command;
|
|
|
|
|
use std::env;
|
2018-01-31 18:30:01 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
fn main() {
|
|
|
|
|
let mut cmd = Command::new("rustc");
|
|
|
|
|
for arg in env::args_os().skip(1) {
|
|
|
|
|
cmd.arg(arg);
|
|
|
|
|
}
|
|
|
|
|
std::process::exit(cmd.status().unwrap().code().unwrap());
|
2018-01-31 18:30:01 +00:00
|
|
|
|
}
|
2020-09-27 00:59:58 +00:00
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("build").run();
|
2018-01-31 18:30:01 +00:00
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
let src = p
|
|
|
|
|
.root()
|
2018-01-31 18:30:01 +00:00
|
|
|
|
.join("target/debug/foo")
|
|
|
|
|
.with_extension(env::consts::EXE_EXTENSION);
|
|
|
|
|
|
|
|
|
|
Package::new("a", "0.1.0").publish();
|
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
let p = project()
|
|
|
|
|
.at("lib")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "lib"
|
|
|
|
|
version = "0.1.0"
|
2018-01-31 18:30:01 +00:00
|
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[dependencies]
|
|
|
|
|
a = "0.1"
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("src/lib.rs", "")
|
2018-01-31 18:30:01 +00:00
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
fs::copy(&src, p.root().join(src.file_name().unwrap())).unwrap();
|
|
|
|
|
|
|
|
|
|
let file = format!("./foo{}", env::consts::EXE_SUFFIX);
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("build").env("RUSTC", &file).run();
|
2018-01-31 18:30:01 +00:00
|
|
|
|
}
|
2018-05-01 03:39:07 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2018-05-01 03:39:07 +00:00
|
|
|
|
fn ws_rustc_err() {
|
2018-07-20 17:41:44 +00:00
|
|
|
|
let p = project()
|
2018-05-01 03:39:07 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["a"]
|
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
|
)
|
|
|
|
|
.file("a/Cargo.toml", &basic_lib_manifest("a"))
|
2018-05-01 03:39:07 +00:00
|
|
|
|
.file("a/src/lib.rs", "")
|
|
|
|
|
.build();
|
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("rustc")
|
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr("[ERROR] [..]against an actual package[..]")
|
|
|
|
|
.run();
|
2018-05-01 03:39:07 +00:00
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
|
p.cargo("rustdoc")
|
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr("[ERROR] [..]against an actual package[..]")
|
|
|
|
|
.run();
|
2018-05-01 03:39:07 +00:00
|
|
|
|
}
|
2018-11-07 17:00:54 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2018-11-07 17:00:54 +00:00
|
|
|
|
fn ws_err_unused() {
|
2024-01-08 21:34:38 +00:00
|
|
|
|
for table in &[
|
2018-11-07 17:00:54 +00:00
|
|
|
|
"[lib]",
|
|
|
|
|
"[[bin]]",
|
|
|
|
|
"[[example]]",
|
|
|
|
|
"[[test]]",
|
|
|
|
|
"[[bench]]",
|
|
|
|
|
"[dependencies]",
|
|
|
|
|
"[dev-dependencies]",
|
|
|
|
|
"[build-dependencies]",
|
|
|
|
|
"[features]",
|
|
|
|
|
"[target]",
|
|
|
|
|
"[badges]",
|
2023-12-11 20:10:01 +00:00
|
|
|
|
"[lints]",
|
2018-11-07 17:00:54 +00:00
|
|
|
|
] {
|
2024-01-08 21:34:38 +00:00
|
|
|
|
let key = table.trim_start_matches('[').trim_end_matches(']');
|
2018-11-07 17:00:54 +00:00
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
&format!(
|
|
|
|
|
r#"
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["a"]
|
|
|
|
|
|
2024-01-08 21:34:38 +00:00
|
|
|
|
{table}
|
2018-11-07 17:00:54 +00:00
|
|
|
|
"#,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.file("a/Cargo.toml", &basic_lib_manifest("a"))
|
|
|
|
|
.file("a/src/lib.rs", "")
|
|
|
|
|
.build();
|
|
|
|
|
p.cargo("check")
|
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(&format!(
|
|
|
|
|
"\
|
|
|
|
|
[ERROR] failed to parse manifest at `[..]/foo/Cargo.toml`
|
|
|
|
|
|
|
|
|
|
Caused by:
|
2024-01-08 21:34:38 +00:00
|
|
|
|
this virtual manifest specifies a `{key}` section, which is not allowed
|
2018-11-07 17:00:54 +00:00
|
|
|
|
",
|
|
|
|
|
))
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2018-11-07 17:00:54 +00:00
|
|
|
|
fn ws_warn_unused() {
|
|
|
|
|
for (key, name) in &[
|
|
|
|
|
("[profile.dev]\nopt-level = 1", "profiles"),
|
|
|
|
|
("[replace]\n\"bar:0.1.0\" = { path = \"bar\" }", "replace"),
|
|
|
|
|
("[patch.crates-io]\nbar = { path = \"bar\" }", "patch"),
|
|
|
|
|
] {
|
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["a"]
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"a/Cargo.toml",
|
|
|
|
|
&format!(
|
|
|
|
|
r#"
|
|
|
|
|
[package]
|
|
|
|
|
name = "a"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
|
|
{}
|
|
|
|
|
"#,
|
|
|
|
|
key
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.file("a/src/lib.rs", "")
|
|
|
|
|
.build();
|
|
|
|
|
p.cargo("check")
|
|
|
|
|
.with_stderr_contains(&format!(
|
|
|
|
|
"\
|
|
|
|
|
[WARNING] {} for the non root package will be ignored, specify {} at the workspace root:
|
|
|
|
|
package: [..]/foo/a/Cargo.toml
|
|
|
|
|
workspace: [..]/foo/Cargo.toml
|
|
|
|
|
",
|
|
|
|
|
name, name
|
|
|
|
|
))
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-07 18:43:19 +00:00
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
|
#[cargo_test]
|
2018-11-07 18:43:19 +00:00
|
|
|
|
fn ws_warn_path() {
|
|
|
|
|
// Warnings include path to manifest.
|
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["a"]
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"a/Cargo.toml",
|
|
|
|
|
r#"
|
|
|
|
|
cargo-features = ["edition"]
|
|
|
|
|
[package]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file("a/src/lib.rs", "")
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
|
.with_stderr_contains("[WARNING] [..]/foo/a/Cargo.toml: the cargo feature `edition`[..]")
|
|
|
|
|
.run();
|
|
|
|
|
}
|
2019-07-10 17:01:09 +00:00
|
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
|
fn invalid_missing() {
|
2020-02-25 18:17:11 +00:00
|
|
|
|
// Make sure errors are not suppressed with -q.
|
2019-07-10 17:01:09 +00:00
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
|
|
|
|
[package]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
x = { path = 'x' }
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
|
.build();
|
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check -q")
|
2019-07-10 17:01:09 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
|
|
|
|
"\
|
2020-02-27 16:17:18 +00:00
|
|
|
|
[ERROR] failed to get `x` as a dependency of package `foo v0.1.0 [..]`
|
2019-07-10 17:01:09 +00:00
|
|
|
|
|
|
|
|
|
Caused by:
|
2020-02-25 18:17:11 +00:00
|
|
|
|
failed to load source for dependency `x`
|
2019-07-10 17:01:09 +00:00
|
|
|
|
|
|
|
|
|
Caused by:
|
2020-02-25 18:17:11 +00:00
|
|
|
|
Unable to update [..]/foo/x
|
2019-07-10 17:01:09 +00:00
|
|
|
|
|
|
|
|
|
Caused by:
|
2020-02-25 18:17:11 +00:00
|
|
|
|
failed to read `[..]foo/x/Cargo.toml`
|
|
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
|
[..]
|
|
|
|
|
",
|
2019-07-10 17:01:09 +00:00
|
|
|
|
)
|
|
|
|
|
.run();
|
|
|
|
|
}
|
2020-10-12 14:01:49 +00:00
|
|
|
|
|
2021-04-17 06:24:29 +00:00
|
|
|
|
#[cargo_test]
|
|
|
|
|
fn member_dep_missing() {
|
|
|
|
|
// Make sure errors are not suppressed with -q.
|
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2021-04-17 06:24:29 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2021-04-17 06:24:29 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
baz = { path = "baz" }
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
|
.build();
|
|
|
|
|
|
2023-02-16 03:14:51 +00:00
|
|
|
|
p.cargo("check -q")
|
2021-04-17 06:24:29 +00:00
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr(
|
|
|
|
|
"\
|
|
|
|
|
[ERROR] failed to load manifest for workspace member `[..]/bar`
|
|
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
|
failed to load manifest for dependency `baz`
|
|
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
|
failed to read `[..]foo/bar/baz/Cargo.toml`
|
|
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
|
[..]
|
|
|
|
|
",
|
|
|
|
|
)
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-12 14:01:49 +00:00
|
|
|
|
#[cargo_test]
|
|
|
|
|
fn simple_primary_package_env_var() {
|
2020-10-14 22:44:04 +00:00
|
|
|
|
let is_primary_package = r#"
|
|
|
|
|
#[test]
|
|
|
|
|
fn verify_primary_package() {{
|
|
|
|
|
assert!(option_env!("CARGO_PRIMARY_PACKAGE").is_some());
|
|
|
|
|
}}
|
|
|
|
|
"#;
|
|
|
|
|
|
2020-10-12 14:01:49 +00:00
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-10-12 14:01:49 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
"#,
|
|
|
|
|
)
|
2020-10-14 22:44:04 +00:00
|
|
|
|
.file("src/lib.rs", is_primary_package)
|
2020-10-12 14:01:49 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2020-10-12 14:01:49 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = ".."
|
|
|
|
|
"#,
|
|
|
|
|
)
|
2020-10-14 22:44:04 +00:00
|
|
|
|
.file("bar/src/lib.rs", is_primary_package);
|
2020-10-12 14:01:49 +00:00
|
|
|
|
let p = p.build();
|
|
|
|
|
|
2020-10-14 22:44:04 +00:00
|
|
|
|
p.cargo("test").run();
|
2020-10-12 14:01:49 +00:00
|
|
|
|
|
|
|
|
|
// Again, this time selecting a specific crate
|
|
|
|
|
p.cargo("clean").run();
|
2020-10-14 22:44:04 +00:00
|
|
|
|
p.cargo("test -p bar").run();
|
2020-10-12 14:01:49 +00:00
|
|
|
|
|
|
|
|
|
// Again, this time selecting all crates
|
|
|
|
|
p.cargo("clean").run();
|
2020-10-14 22:44:04 +00:00
|
|
|
|
p.cargo("test --all").run();
|
2020-10-12 14:01:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
|
fn virtual_primary_package_env_var() {
|
2020-10-14 22:44:04 +00:00
|
|
|
|
let is_primary_package = r#"
|
|
|
|
|
#[test]
|
|
|
|
|
fn verify_primary_package() {{
|
|
|
|
|
assert!(option_env!("CARGO_PRIMARY_PACKAGE").is_some());
|
|
|
|
|
}}
|
|
|
|
|
"#;
|
|
|
|
|
|
2020-10-12 14:01:49 +00:00
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo", "bar"]
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
2020-10-14 22:44:04 +00:00
|
|
|
|
.file("foo/src/lib.rs", is_primary_package)
|
2020-10-12 14:01:49 +00:00
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2020-10-14 22:44:04 +00:00
|
|
|
|
.file("bar/src/lib.rs", is_primary_package);
|
2020-10-12 14:01:49 +00:00
|
|
|
|
let p = p.build();
|
|
|
|
|
|
2020-10-14 22:44:04 +00:00
|
|
|
|
p.cargo("test").run();
|
2020-10-12 14:01:49 +00:00
|
|
|
|
|
|
|
|
|
// Again, this time selecting a specific crate
|
|
|
|
|
p.cargo("clean").run();
|
2020-10-14 22:44:04 +00:00
|
|
|
|
p.cargo("test -p foo").run();
|
2020-10-12 14:01:49 +00:00
|
|
|
|
}
|
2022-07-14 02:10:22 +00:00
|
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
|
fn ensure_correct_workspace_when_nested() {
|
|
|
|
|
let p = project()
|
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
|
|
|
|
[workspace]
|
|
|
|
|
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2022-07-14 02:10:22 +00:00
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
|
.file(
|
|
|
|
|
"sub/Cargo.toml",
|
|
|
|
|
r#"
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo"]
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"sub/foo/Cargo.toml",
|
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
|
[package]
|
2022-07-14 02:10:22 +00:00
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "../.."}
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file("sub/foo/src/main.rs", "fn main() {}");
|
|
|
|
|
let p = p.build();
|
|
|
|
|
p.cargo("tree")
|
|
|
|
|
.cwd("sub/foo")
|
|
|
|
|
.with_stdout(
|
|
|
|
|
"\
|
|
|
|
|
foo v0.1.0 ([..]/foo/sub/foo)
|
|
|
|
|
└── bar v0.1.0 ([..]/foo)\
|
|
|
|
|
",
|
|
|
|
|
)
|
|
|
|
|
.run();
|
|
|
|
|
}
|