2018-04-09 18:31:04 +00:00
|
|
|
use cargotest::rustc_host;
|
|
|
|
use cargotest::support::registry::Package;
|
|
|
|
use cargotest::support::{cross_compile, execs, project};
|
2014-09-11 18:50:57 +00:00
|
|
|
use hamcrest::assert_that;
|
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn no_deps() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2014-09-11 18:50:57 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
authors = []
|
|
|
|
version = "0.0.1"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2014-09-11 18:50:57 +00:00
|
|
|
mod a; fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/a.rs", "")
|
|
|
|
.build();
|
2014-09-11 18:50:57 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(p.cargo("fetch"), execs().with_status(0).with_stdout(""));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2018-04-09 18:31:04 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn fetch_all_platform_dependencies_when_no_target_is_given() {
|
|
|
|
Package::new("d1", "1.2.3")
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[project]
|
|
|
|
name = "d1"
|
|
|
|
version = "1.2.3"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
Package::new("d2", "0.1.2")
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[project]
|
|
|
|
name = "d2"
|
|
|
|
version = "0.1.2"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let target = cross_compile::alternate();
|
|
|
|
let host = rustc_host();
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-04-09 18:31:04 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[target.{host}.dependencies]
|
|
|
|
d1 = "1.2.3"
|
|
|
|
|
|
|
|
[target.{target}.dependencies]
|
|
|
|
d2 = "0.1.2"
|
|
|
|
"#,
|
|
|
|
host = host,
|
|
|
|
target = target
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
p.cargo("fetch"),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
|
|
|
.with_stderr_contains("[..] Downloading d1 v1.2.3 [..]")
|
|
|
|
.with_stderr_contains("[..] Downloading d2 v0.1.2 [..]"),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn fetch_platform_specific_dependencies() {
|
|
|
|
Package::new("d1", "1.2.3")
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[project]
|
|
|
|
name = "d1"
|
|
|
|
version = "1.2.3"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
Package::new("d2", "0.1.2")
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[project]
|
|
|
|
name = "d2"
|
|
|
|
version = "0.1.2"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let target = cross_compile::alternate();
|
|
|
|
let host = rustc_host();
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-04-09 18:31:04 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[target.{host}.dependencies]
|
|
|
|
d1 = "1.2.3"
|
|
|
|
|
|
|
|
[target.{target}.dependencies]
|
|
|
|
d2 = "0.1.2"
|
|
|
|
"#,
|
|
|
|
host = host,
|
|
|
|
target = target
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
p.cargo("fetch").arg("--target").arg(&host),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
|
|
|
.with_stderr_contains("[..] Downloading d1 v1.2.3 [..]")
|
|
|
|
.with_stderr_does_not_contain("[..] Downloading d2 v0.1.2 [..]"),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
p.cargo("fetch").arg("--target").arg(&target),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
|
|
|
.with_stderr_contains("[..] Downloading d2 v0.1.2[..]")
|
|
|
|
.with_stderr_does_not_contain("[..] Downloading d1 v1.2.3 [..]"),
|
|
|
|
);
|
|
|
|
}
|