2018-07-24 22:35:01 +00:00
|
|
|
use support::{basic_manifest, basic_bin_manifest, execs, main_file, project};
|
2018-07-21 21:17:44 +00:00
|
|
|
use support::hamcrest::{assert_that, existing_file, is_not};
|
2017-08-03 14:02:00 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cargo_build_plan_simple() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2017-08-03 14:02:00 +00:00
|
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
|
|
|
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
|
|
|
|
.build();
|
|
|
|
|
|
|
|
assert_that(
|
2018-08-18 20:34:09 +00:00
|
|
|
p.cargo("build --build-plan -Zunstable-options")
|
|
|
|
.masquerade_as_nightly_cargo(),
|
2018-08-02 10:29:39 +00:00
|
|
|
execs().with_json(
|
2017-08-03 14:02:00 +00:00
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"inputs": [
|
2018-08-02 09:18:48 +00:00
|
|
|
"[..]/foo/Cargo.toml"
|
2017-08-03 14:02:00 +00:00
|
|
|
],
|
|
|
|
"invocations": [
|
|
|
|
{
|
|
|
|
"args": "{...}",
|
2018-08-02 09:18:48 +00:00
|
|
|
"cwd": "[..]/cit/[..]/foo",
|
2017-08-03 14:02:00 +00:00
|
|
|
"deps": [],
|
|
|
|
"env": "{...}",
|
|
|
|
"kind": "Host",
|
|
|
|
"links": "{...}",
|
|
|
|
"outputs": "{...}",
|
|
|
|
"package_name": "foo",
|
|
|
|
"package_version": "0.5.0",
|
|
|
|
"program": "rustc",
|
|
|
|
"target_kind": ["bin"]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
assert_that(&p.bin("foo"), is_not(existing_file()));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cargo_build_plan_single_dep() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2017-08-03 14:02:00 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
authors = []
|
|
|
|
version = "0.5.0"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { path = "bar" }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
|
|
|
extern crate bar;
|
|
|
|
pub fn foo() { bar::bar(); }
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test() { foo(); }
|
|
|
|
"#,
|
|
|
|
)
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
2017-08-03 14:02:00 +00:00
|
|
|
.file("bar/src/lib.rs", "pub fn bar() {}")
|
|
|
|
.build();
|
|
|
|
assert_that(
|
2018-08-18 20:34:09 +00:00
|
|
|
p.cargo("build --build-plan -Zunstable-options")
|
|
|
|
.masquerade_as_nightly_cargo(),
|
2018-08-02 10:29:39 +00:00
|
|
|
execs().with_json(
|
2017-08-03 14:02:00 +00:00
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"inputs": [
|
2018-08-02 09:18:48 +00:00
|
|
|
"[..]/foo/Cargo.toml",
|
|
|
|
"[..]/foo/bar/Cargo.toml"
|
2017-08-03 14:02:00 +00:00
|
|
|
],
|
|
|
|
"invocations": [
|
|
|
|
{
|
|
|
|
"args": "{...}",
|
2018-08-02 09:18:48 +00:00
|
|
|
"cwd": "[..]/cit/[..]/foo",
|
2017-08-03 14:02:00 +00:00
|
|
|
"deps": [],
|
|
|
|
"env": "{...}",
|
|
|
|
"kind": "Host",
|
|
|
|
"links": "{...}",
|
|
|
|
"outputs": [
|
2018-08-02 09:18:48 +00:00
|
|
|
"[..]/foo/target/debug/deps/libbar-[..].rlib"
|
2017-08-03 14:02:00 +00:00
|
|
|
],
|
|
|
|
"package_name": "bar",
|
|
|
|
"package_version": "0.0.1",
|
|
|
|
"program": "rustc",
|
|
|
|
"target_kind": ["lib"]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"args": "{...}",
|
2018-08-02 09:18:48 +00:00
|
|
|
"cwd": "[..]/cit/[..]/foo",
|
2017-08-03 14:02:00 +00:00
|
|
|
"deps": [0],
|
|
|
|
"env": "{...}",
|
|
|
|
"kind": "Host",
|
|
|
|
"links": "{...}",
|
|
|
|
"outputs": [
|
2018-08-02 09:18:48 +00:00
|
|
|
"[..]/foo/target/debug/deps/libfoo-[..].rlib"
|
2017-08-03 14:02:00 +00:00
|
|
|
],
|
|
|
|
"package_name": "foo",
|
|
|
|
"package_version": "0.5.0",
|
|
|
|
"program": "rustc",
|
|
|
|
"target_kind": ["lib"]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn cargo_build_plan_build_script() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2017-08-03 14:02:00 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
build = "build.rs"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", r#"fn main() {}"#)
|
|
|
|
.file("build.rs", r#"fn main() {}"#)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
assert_that(
|
2018-08-18 20:34:09 +00:00
|
|
|
p.cargo("build --build-plan -Zunstable-options")
|
|
|
|
.masquerade_as_nightly_cargo(),
|
2018-08-02 10:29:39 +00:00
|
|
|
execs().with_json(
|
2017-08-03 14:02:00 +00:00
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"inputs": [
|
2018-08-02 09:18:48 +00:00
|
|
|
"[..]/foo/Cargo.toml"
|
2017-08-03 14:02:00 +00:00
|
|
|
],
|
|
|
|
"invocations": [
|
|
|
|
{
|
|
|
|
"args": "{...}",
|
2018-08-02 09:18:48 +00:00
|
|
|
"cwd": "[..]/cit/[..]/foo",
|
2017-08-03 14:02:00 +00:00
|
|
|
"deps": [],
|
|
|
|
"env": "{...}",
|
|
|
|
"kind": "Host",
|
|
|
|
"links": "{...}",
|
|
|
|
"outputs": [
|
2018-08-02 09:18:48 +00:00
|
|
|
"[..]/foo/target/debug/build/[..]/build_script_build-[..]"
|
2017-08-03 14:02:00 +00:00
|
|
|
],
|
|
|
|
"package_name": "foo",
|
|
|
|
"package_version": "0.5.0",
|
|
|
|
"program": "rustc",
|
|
|
|
"target_kind": ["custom-build"]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"args": "{...}",
|
2018-08-02 09:18:48 +00:00
|
|
|
"cwd": "[..]/cit/[..]/foo",
|
2017-08-03 14:02:00 +00:00
|
|
|
"deps": [0],
|
|
|
|
"env": "{...}",
|
|
|
|
"kind": "Host",
|
|
|
|
"links": "{...}",
|
|
|
|
"outputs": [],
|
|
|
|
"package_name": "foo",
|
|
|
|
"package_version": "0.5.0",
|
2018-08-02 09:18:48 +00:00
|
|
|
"program": "[..]/build-script-build",
|
2017-08-03 14:02:00 +00:00
|
|
|
"target_kind": ["custom-build"]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"args": "{...}",
|
2018-08-02 09:18:48 +00:00
|
|
|
"cwd": "[..]/cit/[..]/foo",
|
2017-08-03 14:02:00 +00:00
|
|
|
"deps": [1],
|
|
|
|
"env": "{...}",
|
|
|
|
"kind": "Host",
|
|
|
|
"links": "{...}",
|
|
|
|
"outputs": "{...}",
|
|
|
|
"package_name": "foo",
|
|
|
|
"package_version": "0.5.0",
|
|
|
|
"program": "rustc",
|
|
|
|
"target_kind": ["bin"]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|