1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
//! Tests for the `cargo fetch` command.
use cargo_test_support::registry::Package;
use cargo_test_support::rustc_host;
use cargo_test_support::{basic_manifest, cross_compile, project};
#[cargo_test]
fn no_deps() {
let p = project()
.file("src/main.rs", "mod a; fn main() {}")
.file("src/a.rs", "")
.build();
p.cargo("fetch").with_stdout("").run();
}
#[allow(dead_code)]
fn _fetch_all_platform_dependencies_when_no_target_is_given() {
if cross_compile::disabled() {
return;
}
Package::new("d1", "1.2.3")
.file("Cargo.toml", &basic_manifest("d1", "1.2.3"))
.file("src/lib.rs", "")
.publish();
Package::new("d2", "0.1.2")
.file("Cargo.toml", &basic_manifest("d2", "0.1.2"))
.file("src/lib.rs", "")
.publish();
let target = cross_compile::alternate();
let host = rustc_host();
let p = project()
.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();
p.cargo("fetch")
.with_stderr_contains("[DOWNLOADED] d1 v1.2.3 [..]")
.with_stderr_contains("[DOWNLOADED] d2 v0.1.2 [..]")
.run();
}
#[allow(dead_code)]
fn _fetch_platform_specific_dependencies() {
if cross_compile::disabled() {
return;
}
Package::new("d1", "1.2.3")
.file("Cargo.toml", &basic_manifest("d1", "1.2.3"))
.file("src/lib.rs", "")
.publish();
Package::new("d2", "0.1.2")
.file("Cargo.toml", &basic_manifest("d2", "0.1.2"))
.file("src/lib.rs", "")
.publish();
let target = cross_compile::alternate();
let host = rustc_host();
let p = project()
.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();
p.cargo("fetch --target")
.arg(&host)
.with_stderr_contains("[DOWNLOADED] d1 v1.2.3 [..]")
.with_stderr_does_not_contain("[DOWNLOADED] d2 v0.1.2 [..]")
.run();
p.cargo("fetch --target")
.arg(&target)
.with_stderr_contains("[DOWNLOADED] d2 v0.1.2[..]")
.with_stderr_does_not_contain("[DOWNLOADED] d1 v1.2.3 [..]")
.run();
}
#[cargo_test]
fn fetch_warning() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "1.0.0"
misspelled = "wut"
"#,
)
.file("src/lib.rs", "")
.build();
p.cargo("fetch")
.with_stderr("[WARNING] unused manifest key: package.misspelled")
.run();
}
|