2020-03-08 22:12:18 +00:00
|
|
|
//! Tests for --unit-graph option.
|
|
|
|
|
|
|
|
use cargo_test_support::project;
|
|
|
|
use cargo_test_support::registry::Package;
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn gated() {
|
|
|
|
let p = project().file("src/lib.rs", "").build();
|
|
|
|
p.cargo("build --unit-graph")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] the `--unit-graph` flag is unstable[..]
|
|
|
|
See [..]
|
|
|
|
See [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn simple() {
|
|
|
|
Package::new("a", "1.0.0")
|
|
|
|
.dep("b", "1.0")
|
|
|
|
.feature("feata", &["b/featb"])
|
|
|
|
.publish();
|
|
|
|
Package::new("b", "1.0.0")
|
|
|
|
.dep("c", "1.0")
|
|
|
|
.feature("featb", &["c/featc"])
|
|
|
|
.publish();
|
|
|
|
Package::new("c", "1.0.0").feature("featc", &[]).publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
a = "1.0"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build --features a/feata --unit-graph -Zunstable-options")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["unit-graph"])
|
2020-03-08 22:12:18 +00:00
|
|
|
.with_json(
|
|
|
|
r#"{
|
2021-01-31 17:08:47 +00:00
|
|
|
"roots": [
|
|
|
|
3
|
|
|
|
],
|
2020-09-27 00:59:58 +00:00
|
|
|
"units": [
|
|
|
|
{
|
2021-01-31 17:08:47 +00:00
|
|
|
"dependencies": [
|
|
|
|
{
|
|
|
|
"extern_crate_name": "b",
|
|
|
|
"index": 1,
|
|
|
|
"noprelude": false,
|
|
|
|
"public": false
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"features": [
|
|
|
|
"feata"
|
|
|
|
],
|
|
|
|
"mode": "build",
|
2020-09-27 00:59:58 +00:00
|
|
|
"pkg_id": "a 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
2021-01-31 17:08:47 +00:00
|
|
|
"platform": null,
|
|
|
|
"profile": {
|
|
|
|
"codegen_backend": null,
|
|
|
|
"codegen_units": null,
|
|
|
|
"debug_assertions": true,
|
|
|
|
"debuginfo": 2,
|
|
|
|
"incremental": false,
|
|
|
|
"lto": "false",
|
|
|
|
"name": "dev",
|
|
|
|
"opt_level": "0",
|
|
|
|
"overflow_checks": true,
|
|
|
|
"panic": "unwind",
|
|
|
|
"rpath": false,
|
2021-08-05 15:17:50 +00:00
|
|
|
"split_debuginfo": "{...}",
|
2024-01-06 16:36:56 +00:00
|
|
|
"strip": "{...}"
|
2021-01-31 17:08:47 +00:00
|
|
|
},
|
2020-09-27 00:59:58 +00:00
|
|
|
"target": {
|
2021-01-31 17:08:47 +00:00
|
|
|
"crate_types": [
|
2020-09-27 00:59:58 +00:00
|
|
|
"lib"
|
|
|
|
],
|
2021-01-31 17:08:47 +00:00
|
|
|
"doc": true,
|
|
|
|
"doctest": true,
|
|
|
|
"edition": "2015",
|
|
|
|
"kind": [
|
2020-09-27 00:59:58 +00:00
|
|
|
"lib"
|
|
|
|
],
|
|
|
|
"name": "a",
|
|
|
|
"src_path": "[..]/a-1.0.0/src/lib.rs",
|
|
|
|
"test": true
|
2021-01-31 17:08:47 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"dependencies": [
|
|
|
|
{
|
|
|
|
"extern_crate_name": "c",
|
|
|
|
"index": 2,
|
|
|
|
"noprelude": false,
|
|
|
|
"public": false
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"features": [
|
|
|
|
"featb"
|
|
|
|
],
|
|
|
|
"mode": "build",
|
|
|
|
"pkg_id": "b 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
|
|
"platform": null,
|
2020-09-27 00:59:58 +00:00
|
|
|
"profile": {
|
2021-01-31 17:08:47 +00:00
|
|
|
"codegen_backend": null,
|
2020-09-27 00:59:58 +00:00
|
|
|
"codegen_units": null,
|
|
|
|
"debug_assertions": true,
|
2021-01-31 17:08:47 +00:00
|
|
|
"debuginfo": 2,
|
2020-09-27 00:59:58 +00:00
|
|
|
"incremental": false,
|
2021-01-31 17:08:47 +00:00
|
|
|
"lto": "false",
|
|
|
|
"name": "dev",
|
|
|
|
"opt_level": "0",
|
|
|
|
"overflow_checks": true,
|
2020-09-27 00:59:58 +00:00
|
|
|
"panic": "unwind",
|
2021-01-31 17:08:47 +00:00
|
|
|
"rpath": false,
|
2021-08-05 15:17:50 +00:00
|
|
|
"split_debuginfo": "{...}",
|
2024-01-06 16:36:56 +00:00
|
|
|
"strip": "{...}"
|
2020-09-27 00:59:58 +00:00
|
|
|
},
|
|
|
|
"target": {
|
2021-01-31 17:08:47 +00:00
|
|
|
"crate_types": [
|
2020-09-27 00:59:58 +00:00
|
|
|
"lib"
|
|
|
|
],
|
2021-01-31 17:08:47 +00:00
|
|
|
"doc": true,
|
|
|
|
"doctest": true,
|
|
|
|
"edition": "2015",
|
|
|
|
"kind": [
|
2020-09-27 00:59:58 +00:00
|
|
|
"lib"
|
|
|
|
],
|
|
|
|
"name": "b",
|
|
|
|
"src_path": "[..]/b-1.0.0/src/lib.rs",
|
|
|
|
"test": true
|
2021-01-31 17:08:47 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"dependencies": [],
|
|
|
|
"features": [
|
|
|
|
"featc"
|
|
|
|
],
|
|
|
|
"mode": "build",
|
|
|
|
"pkg_id": "c 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
|
|
"platform": null,
|
2020-09-27 00:59:58 +00:00
|
|
|
"profile": {
|
2021-01-31 17:08:47 +00:00
|
|
|
"codegen_backend": null,
|
2020-09-27 00:59:58 +00:00
|
|
|
"codegen_units": null,
|
|
|
|
"debug_assertions": true,
|
2021-01-31 17:08:47 +00:00
|
|
|
"debuginfo": 2,
|
2020-09-27 00:59:58 +00:00
|
|
|
"incremental": false,
|
2021-01-31 17:08:47 +00:00
|
|
|
"lto": "false",
|
|
|
|
"name": "dev",
|
|
|
|
"opt_level": "0",
|
|
|
|
"overflow_checks": true,
|
2020-09-27 00:59:58 +00:00
|
|
|
"panic": "unwind",
|
2021-01-31 17:08:47 +00:00
|
|
|
"rpath": false,
|
2021-08-05 15:17:50 +00:00
|
|
|
"split_debuginfo": "{...}",
|
2024-01-06 16:36:56 +00:00
|
|
|
"strip": "{...}"
|
2020-09-27 00:59:58 +00:00
|
|
|
},
|
|
|
|
"target": {
|
2021-01-31 17:08:47 +00:00
|
|
|
"crate_types": [
|
2020-09-27 00:59:58 +00:00
|
|
|
"lib"
|
|
|
|
],
|
2021-01-31 17:08:47 +00:00
|
|
|
"doc": true,
|
|
|
|
"doctest": true,
|
|
|
|
"edition": "2015",
|
|
|
|
"kind": [
|
2020-09-27 00:59:58 +00:00
|
|
|
"lib"
|
|
|
|
],
|
|
|
|
"name": "c",
|
|
|
|
"src_path": "[..]/c-1.0.0/src/lib.rs",
|
2021-01-31 17:08:47 +00:00
|
|
|
"test": true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"dependencies": [
|
|
|
|
{
|
|
|
|
"extern_crate_name": "a",
|
|
|
|
"index": 0,
|
|
|
|
"noprelude": false,
|
|
|
|
"public": false
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"features": [],
|
|
|
|
"mode": "build",
|
|
|
|
"pkg_id": "foo 0.1.0 (path+file://[..]/foo)",
|
|
|
|
"platform": null,
|
2020-09-27 00:59:58 +00:00
|
|
|
"profile": {
|
2021-01-31 17:08:47 +00:00
|
|
|
"codegen_backend": null,
|
2020-09-27 00:59:58 +00:00
|
|
|
"codegen_units": null,
|
|
|
|
"debug_assertions": true,
|
2021-01-31 17:08:47 +00:00
|
|
|
"debuginfo": 2,
|
2020-09-27 00:59:58 +00:00
|
|
|
"incremental": false,
|
2021-01-31 17:08:47 +00:00
|
|
|
"lto": "false",
|
|
|
|
"name": "dev",
|
|
|
|
"opt_level": "0",
|
|
|
|
"overflow_checks": true,
|
2020-09-27 00:59:58 +00:00
|
|
|
"panic": "unwind",
|
2021-01-31 17:08:47 +00:00
|
|
|
"rpath": false,
|
2021-08-05 15:17:50 +00:00
|
|
|
"split_debuginfo": "{...}",
|
2024-01-06 16:36:56 +00:00
|
|
|
"strip": "{...}"
|
2020-09-27 00:59:58 +00:00
|
|
|
},
|
|
|
|
"target": {
|
2021-01-31 17:08:47 +00:00
|
|
|
"crate_types": [
|
2020-09-27 00:59:58 +00:00
|
|
|
"lib"
|
|
|
|
],
|
2021-01-31 17:08:47 +00:00
|
|
|
"doc": true,
|
|
|
|
"doctest": true,
|
|
|
|
"edition": "2015",
|
|
|
|
"kind": [
|
2020-09-27 00:59:58 +00:00
|
|
|
"lib"
|
|
|
|
],
|
|
|
|
"name": "foo",
|
|
|
|
"src_path": "[..]/foo/src/lib.rs",
|
2021-01-31 17:08:47 +00:00
|
|
|
"test": true
|
|
|
|
}
|
2020-09-27 00:59:58 +00:00
|
|
|
}
|
|
|
|
],
|
2021-01-31 17:08:47 +00:00
|
|
|
"version": 1
|
2020-09-27 00:59:58 +00:00
|
|
|
}
|
|
|
|
"#,
|
2020-03-08 22:12:18 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|