2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for normal registry dependencies.
|
|
|
|
|
2021-03-20 20:43:33 +00:00
|
|
|
use cargo::core::SourceId;
|
2022-06-09 03:04:33 +00:00
|
|
|
use cargo_test_support::cargo_process;
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::paths::{self, CargoPathExt};
|
2022-03-09 22:10:22 +00:00
|
|
|
use cargo_test_support::registry::{
|
2022-06-09 03:04:33 +00:00
|
|
|
self, registry_path, Dependency, Package, RegistryBuilder, TestRegistry,
|
2022-03-09 22:10:22 +00:00
|
|
|
};
|
|
|
|
use cargo_test_support::{basic_manifest, project, Execs, Project};
|
2020-11-05 22:24:34 +00:00
|
|
|
use cargo_test_support::{git, install::cargo_home, t};
|
2021-03-20 20:43:33 +00:00
|
|
|
use cargo_util::paths::remove_dir_all;
|
2020-04-17 04:10:11 +00:00
|
|
|
use std::fs::{self, File};
|
|
|
|
use std::path::Path;
|
2022-09-09 20:58:58 +00:00
|
|
|
use std::sync::Mutex;
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
fn cargo_http(p: &Project, s: &str) -> Execs {
|
|
|
|
let mut e = p.cargo(s);
|
2022-07-16 02:32:23 +00:00
|
|
|
e.arg("-Zsparse-registry")
|
|
|
|
.masquerade_as_nightly_cargo(&["sparse-registry"]);
|
2022-03-09 22:10:22 +00:00
|
|
|
e
|
|
|
|
}
|
|
|
|
|
|
|
|
fn cargo_stable(p: &Project, s: &str) -> Execs {
|
|
|
|
p.cargo(s)
|
|
|
|
}
|
|
|
|
|
2022-06-09 03:04:33 +00:00
|
|
|
fn setup_http() -> TestRegistry {
|
|
|
|
RegistryBuilder::new().http_index().build()
|
2022-03-09 22:10:22 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn simple_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
simple(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn simple_git() {
|
|
|
|
simple(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn simple(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = ">= 0.0.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("bar", "0.0.1").publish();
|
2014-10-23 05:05:30 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2021-06-27 19:18:36 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] bar v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2014-09-09 05:26:14 +00:00
|
|
|
",
|
2021-06-27 19:18:36 +00:00
|
|
|
)
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2014-09-09 14:23:09 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "clean").run();
|
2017-02-15 14:16:41 +00:00
|
|
|
|
2022-04-16 14:59:52 +00:00
|
|
|
assert!(paths::home().join(".cargo/registry/CACHEDIR.TAG").is_file());
|
|
|
|
|
2014-09-09 14:23:09 +00:00
|
|
|
// Don't download a second time
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] bar v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2014-09-09 14:23:09 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn deps_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
deps(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn deps_git() {
|
|
|
|
deps(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn deps(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = ">= 0.0.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("baz", "0.0.1").publish();
|
|
|
|
Package::new("bar", "0.0.1").dep("baz", "*").publish();
|
2014-10-23 05:05:30 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2021-06-27 19:18:36 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `dummy-registry`)
|
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] baz v0.0.1
|
|
|
|
[COMPILING] bar v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2014-09-09 05:26:14 +00:00
|
|
|
",
|
2021-06-27 19:18:36 +00:00
|
|
|
)
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2022-04-16 14:59:52 +00:00
|
|
|
|
|
|
|
assert!(paths::home().join(".cargo/registry/CACHEDIR.TAG").is_file());
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn nonexistent_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
nonexistent(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn nonexistent_git() {
|
|
|
|
nonexistent(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn nonexistent(cargo: fn(&Project, &str) -> Execs) {
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("init", "0.0.1").publish();
|
|
|
|
|
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.0.1"
|
|
|
|
authors = []
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
nonexistent = ">= 0.0.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] [..] index
|
2018-02-07 16:51:40 +00:00
|
|
|
error: no matching package named `nonexistent` found
|
2016-02-03 18:54:07 +00:00
|
|
|
location searched: registry [..]
|
2018-02-07 16:51:40 +00:00
|
|
|
required by package `foo v0.0.1 ([..])`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn wrong_case_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
wrong_case(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn wrong_case_git() {
|
|
|
|
wrong_case(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn wrong_case(cargo: fn(&Project, &str) -> Execs) {
|
2018-07-09 22:02:46 +00:00
|
|
|
Package::new("init", "0.0.1").publish();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-07-09 22:02:46 +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.0.1"
|
|
|
|
authors = []
|
2018-07-09 22:02:46 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
Init = ">= 0.0.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-07-09 22:02:46 +00:00
|
|
|
.build();
|
|
|
|
|
2018-07-11 16:46:52 +00:00
|
|
|
// #5678 to make this work
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-07-09 22:02:46 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] [..] index
|
2021-07-10 14:07:29 +00:00
|
|
|
error: no matching package found
|
|
|
|
searched package name: `Init`
|
|
|
|
perhaps you meant: init
|
2018-07-09 22:02:46 +00:00
|
|
|
location searched: registry [..]
|
|
|
|
required by package `foo v0.0.1 ([..])`
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-07-09 22:02:46 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn mis_hyphenated_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
mis_hyphenated(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn mis_hyphenated_git() {
|
|
|
|
mis_hyphenated(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn mis_hyphenated(cargo: fn(&Project, &str) -> Execs) {
|
2018-07-09 22:02:46 +00:00
|
|
|
Package::new("mis-hyphenated", "0.0.1").publish();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-07-09 22:02:46 +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.0.1"
|
|
|
|
authors = []
|
2018-07-09 22:02:46 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
mis_hyphenated = ">= 0.0.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-07-09 22:02:46 +00:00
|
|
|
.build();
|
|
|
|
|
2018-07-11 16:46:52 +00:00
|
|
|
// #2775 to make this work
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-07-09 22:02:46 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] [..] index
|
2021-07-10 14:07:29 +00:00
|
|
|
error: no matching package found
|
|
|
|
searched package name: `mis_hyphenated`
|
|
|
|
perhaps you meant: mis-hyphenated
|
2018-07-09 22:02:46 +00:00
|
|
|
location searched: registry [..]
|
|
|
|
required by package `foo v0.0.1 ([..])`
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-07-09 22:02:46 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn wrong_version_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
wrong_version(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn wrong_version_git() {
|
|
|
|
wrong_version(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn wrong_version(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2015-01-11 07:03:58 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
foo = ">= 1.0.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-01-11 07:03:58 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("foo", "0.0.1").publish();
|
|
|
|
Package::new("foo", "0.0.2").publish();
|
2015-01-11 07:03:58 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2020-05-25 09:47:31 +00:00
|
|
|
error: failed to select a version for the requirement `foo = \">=1.0.0\"`
|
2020-06-25 15:25:52 +00:00
|
|
|
candidate versions found which didn't match: 0.0.2, 0.0.1
|
|
|
|
location searched: `[..]` index (which is replacing registry `[..]`)
|
2018-02-07 16:51:40 +00:00
|
|
|
required by package `foo v0.0.1 ([..])`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2015-01-11 07:03:58 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("foo", "0.0.3").publish();
|
|
|
|
Package::new("foo", "0.0.4").publish();
|
2015-01-11 07:03:58 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2020-05-25 09:47:31 +00:00
|
|
|
error: failed to select a version for the requirement `foo = \">=1.0.0\"`
|
2020-06-25 15:25:52 +00:00
|
|
|
candidate versions found which didn't match: 0.0.4, 0.0.3, 0.0.2, ...
|
|
|
|
location searched: `[..]` index (which is replacing registry `[..]`)
|
2018-02-07 16:51:40 +00:00
|
|
|
required by package `foo v0.0.1 ([..])`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-01-11 07:03:58 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn bad_cksum_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
bad_cksum(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn bad_cksum_git() {
|
|
|
|
bad_cksum(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bad_cksum(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bad-cksum = ">= 0.0.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
let pkg = Package::new("bad-cksum", "0.0.1");
|
|
|
|
pkg.publish();
|
2016-02-05 23:14:17 +00:00
|
|
|
t!(File::create(&pkg.archive_dst()));
|
2014-10-23 05:05:30 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build -v")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.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] bad-cksum [..]
|
2021-06-27 19:18:36 +00:00
|
|
|
[ERROR] failed to download replaced source registry `crates-io`
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2014-09-09 05:26:14 +00:00
|
|
|
Caused by:
|
2021-06-27 19:18:36 +00:00
|
|
|
failed to verify the checksum of `bad-cksum v0.0.1 (registry `dummy-registry`)`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn update_registry_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
update_registry(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn update_registry_git() {
|
|
|
|
update_registry(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn update_registry(cargo: fn(&Project, &str) -> Execs) {
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("init", "0.0.1").publish();
|
|
|
|
|
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.0.1"
|
|
|
|
authors = []
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
notyet = ">= 0.0.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-02-07 16:51:40 +00:00
|
|
|
error: no matching package named `notyet` found
|
|
|
|
location searched: registry `[..]`
|
|
|
|
required by package `foo v0.0.1 ([..])`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("notyet", "0.0.1").publish();
|
2014-09-09 05:26:14 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2021-06-27 19:18:36 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] notyet v0.0.1 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] notyet v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2014-09-09 05:26:14 +00:00
|
|
|
",
|
2021-06-27 19:18:36 +00:00
|
|
|
)
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-09-27 04:14:46 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn package_with_path_deps_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
package_with_path_deps(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn package_with_path_deps_git() {
|
|
|
|
package_with_path_deps(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn package_with_path_deps(cargo: fn(&Project, &str) -> Execs) {
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("init", "0.0.1").publish();
|
|
|
|
|
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.0.1"
|
|
|
|
authors = []
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
repository = "bar"
|
2014-09-27 04:14:46 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.notyet]
|
|
|
|
version = "0.0.1"
|
|
|
|
path = "notyet"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("notyet/Cargo.toml", &basic_manifest("notyet", "0.0.1"))
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("notyet/src/lib.rs", "")
|
|
|
|
.build();
|
2014-09-27 04:14:46 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "package")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2020-04-28 17:49:03 +00:00
|
|
|
[PACKAGING] foo [..]
|
|
|
|
[UPDATING] [..]
|
|
|
|
[ERROR] failed to prepare local package for uploading
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
no matching package named `notyet` found
|
2021-06-27 19:18:36 +00:00
|
|
|
location searched: registry `crates-io`
|
2020-06-25 15:25:52 +00:00
|
|
|
required by package `foo v0.0.1 [..]`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2014-09-27 04:14:46 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("notyet", "0.0.1").publish();
|
2014-09-27 04:14:46 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "package")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2020-02-19 18:46:54 +00:00
|
|
|
[PACKAGING] foo v0.0.1 ([CWD])
|
2020-04-28 17:49:03 +00:00
|
|
|
[UPDATING] `[..]` index
|
2019-06-10 19:38:51 +00:00
|
|
|
[VERIFYING] foo v0.0.1 ([CWD])
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] notyet v0.0.1 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] notyet v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD][..])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-10-23 17:38:44 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn lockfile_locks_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
lockfile_locks(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn lockfile_locks_git() {
|
|
|
|
lockfile_locks(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn lockfile_locks(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2014-10-23 17:38:44 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-10-23 17:38:44 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("bar", "0.0.1").publish();
|
2014-10-23 17:38:44 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-09-03 09:38:29 +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 ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] bar v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2016-05-12 15:23:53 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2014-10-23 17:38:44 +00:00
|
|
|
|
2016-05-26 00:06:25 +00:00
|
|
|
p.root().move_into_the_past();
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("bar", "0.0.2").publish();
|
2014-10-23 17:38:44 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").with_stdout("").run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-10-23 17:38:44 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn lockfile_locks_transitively_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
lockfile_locks_transitively(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn lockfile_locks_transitively_git() {
|
|
|
|
lockfile_locks_transitively(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn lockfile_locks_transitively(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2014-10-23 17:38:44 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-10-23 17:38:44 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("baz", "0.0.1").publish();
|
|
|
|
Package::new("bar", "0.0.1").dep("baz", "*").publish();
|
2014-10-23 17:38:44 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-09-03 09:38:29 +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 ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `dummy-registry`)
|
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] baz v0.0.1
|
|
|
|
[COMPILING] bar v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2016-05-12 15:23:53 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2014-10-23 17:38:44 +00:00
|
|
|
|
2016-05-26 00:06:25 +00:00
|
|
|
p.root().move_into_the_past();
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("baz", "0.0.2").publish();
|
|
|
|
Package::new("bar", "0.0.2").dep("baz", "*").publish();
|
2014-10-23 17:38:44 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").with_stdout("").run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn yanks_are_not_used_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
yanks_are_not_used(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn yanks_are_not_used_git() {
|
|
|
|
yanks_are_not_used(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn yanks_are_not_used(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("baz", "0.0.1").publish();
|
|
|
|
Package::new("baz", "0.0.2").yanked(true).publish();
|
|
|
|
Package::new("bar", "0.0.1").dep("baz", "*").publish();
|
2018-03-14 15:17:44 +00:00
|
|
|
Package::new("bar", "0.0.2")
|
|
|
|
.dep("baz", "*")
|
|
|
|
.yanked(true)
|
|
|
|
.publish();
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-09-03 09:38:29 +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 ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `dummy-registry`)
|
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] baz v0.0.1
|
|
|
|
[COMPILING] bar v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2016-05-12 15:23:53 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn relying_on_a_yank_is_bad_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
relying_on_a_yank_is_bad(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn relying_on_a_yank_is_bad_git() {
|
|
|
|
relying_on_a_yank_is_bad(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn relying_on_a_yank_is_bad(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("baz", "0.0.1").publish();
|
|
|
|
Package::new("baz", "0.0.2").yanked(true).publish();
|
|
|
|
Package::new("bar", "0.0.1").dep("baz", "=0.0.2").publish();
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2020-05-25 09:47:31 +00:00
|
|
|
error: failed to select a version for the requirement `baz = \"=0.0.2\"`
|
2020-06-25 15:25:52 +00:00
|
|
|
candidate versions found which didn't match: 0.0.1
|
|
|
|
location searched: `[..]` index (which is replacing registry `[..]`)
|
2018-02-07 16:51:40 +00:00
|
|
|
required by package `bar v0.0.1`
|
2021-08-22 16:10:15 +00:00
|
|
|
... which satisfies dependency `bar = \"*\"` of package `foo [..]`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn yanks_in_lockfiles_are_ok_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
yanks_in_lockfiles_are_ok(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn yanks_in_lockfiles_are_ok_git() {
|
|
|
|
yanks_in_lockfiles_are_ok(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn yanks_in_lockfiles_are_ok(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("bar", "0.0.1").publish();
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2019-01-11 23:56:46 +00:00
|
|
|
registry_path().join("3").rm_rf();
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("bar", "0.0.1").yanked(true).publish();
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").with_stdout("").run();
|
2014-10-23 19:21:08 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "update")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-02-07 16:51:40 +00:00
|
|
|
error: no matching package named `bar` found
|
2016-02-03 18:54:07 +00:00
|
|
|
location searched: registry [..]
|
2018-02-07 16:51:40 +00:00
|
|
|
required by package `foo v0.0.1 ([..])`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-10-23 20:04:08 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn yanks_in_lockfiles_are_ok_for_other_update_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
yanks_in_lockfiles_are_ok_for_other_update(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn yanks_in_lockfiles_are_ok_for_other_update_git() {
|
|
|
|
yanks_in_lockfiles_are_ok_for_other_update(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn yanks_in_lockfiles_are_ok_for_other_update(cargo: fn(&Project, &str) -> Execs) {
|
2019-01-30 15:53:04 +00:00
|
|
|
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.0.1"
|
|
|
|
authors = []
|
2019-01-30 15:53:04 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
baz = "*"
|
|
|
|
"#,
|
2019-01-30 15:53:04 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("bar", "0.0.1").publish();
|
|
|
|
Package::new("baz", "0.0.1").publish();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
2019-01-30 15:53:04 +00:00
|
|
|
|
|
|
|
registry_path().join("3").rm_rf();
|
|
|
|
|
|
|
|
Package::new("bar", "0.0.1").yanked(true).publish();
|
|
|
|
Package::new("baz", "0.0.1").publish();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").with_stdout("").run();
|
2019-01-30 15:53:04 +00:00
|
|
|
|
|
|
|
Package::new("baz", "0.0.2").publish();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "update")
|
2019-01-30 15:53:04 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
|
|
|
"\
|
|
|
|
error: no matching package named `bar` found
|
|
|
|
location searched: registry [..]
|
|
|
|
required by package `foo v0.0.1 ([..])`
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "update -p baz")
|
2019-01-30 15:53:04 +00:00
|
|
|
.with_stderr_contains(
|
|
|
|
"\
|
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[UPDATING] baz v0.0.1 -> v0.0.2
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn yanks_in_lockfiles_are_ok_with_new_dep_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
yanks_in_lockfiles_are_ok_with_new_dep(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn yanks_in_lockfiles_are_ok_with_new_dep_git() {
|
|
|
|
yanks_in_lockfiles_are_ok_with_new_dep(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn yanks_in_lockfiles_are_ok_with_new_dep(cargo: fn(&Project, &str) -> Execs) {
|
2019-01-30 15:53:04 +00:00
|
|
|
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.0.1"
|
|
|
|
authors = []
|
2019-01-30 15:53:04 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2019-01-30 15:53:04 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("bar", "0.0.1").publish();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
2019-01-30 15:53:04 +00:00
|
|
|
|
|
|
|
registry_path().join("3").rm_rf();
|
|
|
|
|
|
|
|
Package::new("bar", "0.0.1").yanked(true).publish();
|
|
|
|
Package::new("baz", "0.0.1").publish();
|
|
|
|
|
2020-04-17 04:10:11 +00:00
|
|
|
p.change_file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2019-01-30 15:53:04 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
baz = "*"
|
2020-04-17 04:10:11 +00:00
|
|
|
"#,
|
|
|
|
);
|
2019-01-30 15:53:04 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").with_stdout("").run();
|
2019-01-30 15:53:04 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn update_with_lockfile_if_packages_missing_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
update_with_lockfile_if_packages_missing(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn update_with_lockfile_if_packages_missing_git() {
|
|
|
|
update_with_lockfile_if_packages_missing(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn update_with_lockfile_if_packages_missing(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2014-10-23 20:04:08 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-10-23 20:04:08 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("bar", "0.0.1").publish();
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
2016-05-26 00:06:25 +00:00
|
|
|
p.root().move_into_the_past();
|
2014-10-23 20:04:08 +00:00
|
|
|
|
2016-05-26 00:06:25 +00:00
|
|
|
paths::home().join(".cargo/registry").rm_rf();
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
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 ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `dummy-registry`)
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-10-23 20:04:08 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn update_lockfile_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
update_lockfile(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn update_lockfile_git() {
|
|
|
|
update_lockfile(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn update_lockfile(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2014-10-23 20:04:08 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-10-23 20:04:08 +00:00
|
|
|
|
2015-02-04 00:55:07 +00:00
|
|
|
println!("0.0.1");
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("bar", "0.0.1").publish();
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
2014-10-23 20:04:08 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("bar", "0.0.2").publish();
|
|
|
|
Package::new("bar", "0.0.3").publish();
|
2016-05-26 00:06:25 +00:00
|
|
|
paths::home().join(".cargo/registry").rm_rf();
|
2015-02-04 00:55:07 +00:00
|
|
|
println!("0.0.2 update");
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "update -p bar --precise 0.0.2")
|
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
|
2016-02-03 18:54:07 +00:00
|
|
|
[UPDATING] bar v0.0.1 -> v0.0.2
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2014-10-23 20:04:08 +00:00
|
|
|
|
2015-02-04 00:55:07 +00:00
|
|
|
println!("0.0.2 build");
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] [..] v0.0.2 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] bar v0.0.2
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2016-05-12 15:23:53 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2015-02-04 00:55:07 +00:00
|
|
|
|
|
|
|
println!("0.0.3 update");
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "update -p bar")
|
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
|
2016-02-03 18:54:07 +00:00
|
|
|
[UPDATING] bar v0.0.2 -> v0.0.3
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2015-02-04 00:55:07 +00:00
|
|
|
|
|
|
|
println!("0.0.3 build");
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] [..] v0.0.3 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] bar v0.0.3
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2016-05-12 15:23:53 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
|
|
|
println!("new dependencies update");
|
|
|
|
Package::new("bar", "0.0.4").dep("spam", "0.2.5").publish();
|
|
|
|
Package::new("spam", "0.2.5").publish();
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "update -p bar")
|
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
|
2016-02-03 18:54:07 +00:00
|
|
|
[UPDATING] bar v0.0.3 -> v0.0.4
|
|
|
|
[ADDING] spam v0.2.5
|
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
|
|
|
|
|
|
|
println!("new dependencies update");
|
|
|
|
Package::new("bar", "0.0.5").publish();
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "update -p bar")
|
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
|
2016-02-03 18:54:07 +00:00
|
|
|
[UPDATING] bar v0.0.4 -> v0.0.5
|
|
|
|
[REMOVING] spam v0.2.5
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-11-21 02:17:31 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn dev_dependency_not_used_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
dev_dependency_not_used(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn dev_dependency_not_used_git() {
|
|
|
|
dev_dependency_not_used(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn dev_dependency_not_used(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2014-11-21 02:17:31 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-11-21 02:17:31 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("baz", "0.0.1").publish();
|
|
|
|
Package::new("bar", "0.0.1").dev_dep("baz", "*").publish();
|
2014-11-21 02:17:31 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-09-03 09:38:29 +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 ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] bar v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2016-05-12 15:23:53 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-11-21 03:14:58 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn login_with_no_cargo_dir() {
|
2018-12-20 01:40:01 +00:00
|
|
|
// Create a config in the root directory because `login` requires the
|
|
|
|
// index to be updated, and we don't want to hit crates.io.
|
|
|
|
registry::init();
|
|
|
|
fs::rename(paths::home().join(".cargo"), paths::root().join(".cargo")).unwrap();
|
|
|
|
paths::home().rm_rf();
|
2018-08-28 09:20:03 +00:00
|
|
|
cargo_process("login foo -v").run();
|
2018-12-20 01:40:01 +00:00
|
|
|
let credentials = fs::read_to_string(paths::home().join(".cargo/credentials")).unwrap();
|
|
|
|
assert_eq!(credentials, "[registry]\ntoken = \"foo\"\n");
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-11-25 06:18:54 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-08-16 20:51:08 +00:00
|
|
|
fn login_with_differently_sized_token() {
|
2018-12-20 01:40:01 +00:00
|
|
|
// Verify that the configuration file gets properly truncated.
|
|
|
|
registry::init();
|
2019-01-11 23:56:46 +00:00
|
|
|
let credentials = paths::home().join(".cargo/credentials");
|
|
|
|
fs::remove_file(&credentials).unwrap();
|
2018-08-28 09:20:03 +00:00
|
|
|
cargo_process("login lmaolmaolmao -v").run();
|
|
|
|
cargo_process("login lmao -v").run();
|
|
|
|
cargo_process("login lmaolmaolmao -v").run();
|
2019-01-11 23:56:46 +00:00
|
|
|
let credentials = fs::read_to_string(&credentials).unwrap();
|
2018-12-20 01:40:01 +00:00
|
|
|
assert_eq!(credentials, "[registry]\ntoken = \"lmaolmaolmao\"\n");
|
2016-08-16 20:51:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-04 23:05:48 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn login_with_token_on_stdin() {
|
|
|
|
registry::init();
|
|
|
|
let credentials = paths::home().join(".cargo/credentials");
|
|
|
|
fs::remove_file(&credentials).unwrap();
|
|
|
|
cargo_process("login lmao -v").run();
|
2022-06-09 03:04:33 +00:00
|
|
|
cargo_process("login")
|
|
|
|
.with_stdout("please paste the API Token found on [..]/me below")
|
|
|
|
.with_stdin("some token")
|
|
|
|
.run();
|
2022-03-04 23:05:48 +00:00
|
|
|
let credentials = fs::read_to_string(&credentials).unwrap();
|
|
|
|
assert_eq!(credentials, "[registry]\ntoken = \"some token\"\n");
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn bad_license_file_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
bad_license_file(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn bad_license_file_git() {
|
|
|
|
bad_license_file(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bad_license_file(cargo: fn(&Project, &str) -> Execs) {
|
2016-02-22 05:02:20 +00:00
|
|
|
Package::new("foo", "1.0.0").publish();
|
2018-07-20 17:41:44 +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.0.1"
|
|
|
|
authors = []
|
|
|
|
license-file = "foo"
|
|
|
|
description = "bar"
|
|
|
|
repository = "baz"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "publish -v --token sekrit")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains("[ERROR] the license file `foo` does not exist")
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-11-27 23:49:16 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn updating_a_dep_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
updating_a_dep(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn updating_a_dep_git() {
|
|
|
|
updating_a_dep(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn updating_a_dep(cargo: fn(&Project, &str) -> Execs) {
|
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.0.1"
|
|
|
|
authors = []
|
2014-11-27 23:49:16 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.a]
|
|
|
|
path = "a"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"a/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "a"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2014-11-27 23:49:16 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("a/src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-11-27 23:49:16 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("bar", "0.0.1").publish();
|
2014-11-27 23:49:16 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-09-03 09:38:29 +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 ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] bar v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] a v0.0.1 ([CWD]/a)
|
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2016-05-12 15:23:53 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2022-04-16 14:59:52 +00:00
|
|
|
assert!(paths::home().join(".cargo/registry/CACHEDIR.TAG").is_file());
|
2014-11-27 23:49:16 +00:00
|
|
|
|
2022-04-16 15:07:01 +00:00
|
|
|
// Now delete the CACHEDIR.TAG file: this is the situation we'll be in after
|
|
|
|
// upgrading from a version of Cargo that doesn't mark this directory, to one that
|
|
|
|
// does. It should be recreated.
|
|
|
|
fs::remove_file(paths::home().join(".cargo/registry/CACHEDIR.TAG"))
|
|
|
|
.expect("remove CACHEDIR.TAG");
|
|
|
|
|
2020-04-17 04:10:11 +00:00
|
|
|
p.change_file(
|
|
|
|
"a/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2014-11-27 23:49:16 +00:00
|
|
|
name = "a"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
2020-04-17 04:10:11 +00:00
|
|
|
"#,
|
|
|
|
);
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
2014-11-27 23:49:16 +00:00
|
|
|
|
|
|
|
println!("second");
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-09-03 09:38:29 +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 ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] bar v0.1.0 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] bar v0.1.0
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] a v0.0.1 ([CWD]/a)
|
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2016-05-12 15:23:53 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2022-04-16 15:07:01 +00:00
|
|
|
|
|
|
|
assert!(
|
|
|
|
paths::home().join(".cargo/registry/CACHEDIR.TAG").is_file(),
|
|
|
|
"CACHEDIR.TAG recreated in existing registry"
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-12-08 06:25:26 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn git_and_registry_dep_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
git_and_registry_dep(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn git_and_registry_dep_git() {
|
|
|
|
git_and_registry_dep(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn git_and_registry_dep(cargo: fn(&Project, &str) -> Execs) {
|
2014-12-08 06:25:26 +00:00
|
|
|
let b = git::repo(&paths::root().join("b"))
|
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 = "b"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2014-12-08 06:25:26 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
a = "0.0.1"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2014-12-08 06:25:26 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
a = "0.0.1"
|
2014-12-08 06:25:26 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.b]
|
|
|
|
git = '{}'
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
b.url()
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2014-12-08 06:25:26 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("a", "0.0.1").publish();
|
2014-12-08 06:25:26 +00:00
|
|
|
|
2016-05-26 00:06:25 +00:00
|
|
|
p.root().move_into_the_past();
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] [..]
|
|
|
|
[UPDATING] [..]
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] a v0.0.1 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] a v0.0.1
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] b v0.0.1 ([..])
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2016-05-12 15:23:53 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-26 00:06:25 +00:00
|
|
|
p.root().move_into_the_past();
|
2014-12-08 06:25:26 +00:00
|
|
|
|
|
|
|
println!("second");
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").with_stdout("").run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-12-19 21:43:21 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn update_publish_then_update_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
update_publish_then_update(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn update_publish_then_update_git() {
|
|
|
|
update_publish_then_update(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn update_publish_then_update(cargo: fn(&Project, &str) -> Execs) {
|
Add sha256 checksums to the lockfile
This commit changes how lock files are encoded by checksums for each package in
the lockfile to the `[metadata]` section. The previous commit implemented the
ability to redirect sources, but the core assumption there was that a package
coming from two different locations was always the same. An inevitable case,
however, is that a source gets corrupted or, worse, ships a modified version of
a crate to introduce instability between two "mirrors".
The purpose of adding checksums will be to resolve this discrepancy. Each crate
coming from crates.io will now record its sha256 checksum in the lock file. When
a lock file already exists, the new checksum for a crate will be checked against
it, and if they differ compilation will be aborted. Currently only registry
crates will have sha256 checksums listed, all other sources do not have
checksums at this time.
The astute may notice that if the lock file format is changing, then a lock file
generated by a newer Cargo might be mangled by an older Cargo. In anticipation
of this, however, all Cargo versions published support a `[metadata]` section of
the lock file which is transparently carried forward if encountered. This means
that older Cargos compiling with a newer lock file will not verify checksums in
the lock file, but they will carry forward the checksum information and prevent
it from being removed.
There are, however, a few situations where problems may still arise:
1. If an older Cargo takes a newer lockfile (with checksums) and updates it with
a modified `Cargo.toml` (e.g. a package was added, removed, or updated), then
the `[metadata]` section will not be updated appropriately. This modification
would require a newer Cargo to come in and update the checksums for such a
modification.
2. Today Cargo can only calculate checksums for registry sources, but we may
eventually want to support other sources like git (or just straight-up path
sources). If future Cargo implements support for this sort of checksum, then
it's the same problem as above where older Cargos will not know how to keep
the checksum in sync
2016-02-03 19:04:07 +00:00
|
|
|
// First generate a Cargo.lock and a clone of the registry index at the
|
|
|
|
// "head" of the current registry.
|
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 = []
|
2014-12-19 21:43:21 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
a = "0.1.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("a", "0.1.0").publish();
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
2014-12-19 21:43:21 +00:00
|
|
|
|
Add sha256 checksums to the lockfile
This commit changes how lock files are encoded by checksums for each package in
the lockfile to the `[metadata]` section. The previous commit implemented the
ability to redirect sources, but the core assumption there was that a package
coming from two different locations was always the same. An inevitable case,
however, is that a source gets corrupted or, worse, ships a modified version of
a crate to introduce instability between two "mirrors".
The purpose of adding checksums will be to resolve this discrepancy. Each crate
coming from crates.io will now record its sha256 checksum in the lock file. When
a lock file already exists, the new checksum for a crate will be checked against
it, and if they differ compilation will be aborted. Currently only registry
crates will have sha256 checksums listed, all other sources do not have
checksums at this time.
The astute may notice that if the lock file format is changing, then a lock file
generated by a newer Cargo might be mangled by an older Cargo. In anticipation
of this, however, all Cargo versions published support a `[metadata]` section of
the lock file which is transparently carried forward if encountered. This means
that older Cargos compiling with a newer lock file will not verify checksums in
the lock file, but they will carry forward the checksum information and prevent
it from being removed.
There are, however, a few situations where problems may still arise:
1. If an older Cargo takes a newer lockfile (with checksums) and updates it with
a modified `Cargo.toml` (e.g. a package was added, removed, or updated), then
the `[metadata]` section will not be updated appropriately. This modification
would require a newer Cargo to come in and update the checksums for such a
modification.
2. Today Cargo can only calculate checksums for registry sources, but we may
eventually want to support other sources like git (or just straight-up path
sources). If future Cargo implements support for this sort of checksum, then
it's the same problem as above where older Cargos will not know how to keep
the checksum in sync
2016-02-03 19:04:07 +00:00
|
|
|
// Next, publish a new package and back up the copy of the registry we just
|
|
|
|
// created.
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("a", "0.1.1").publish();
|
Add sha256 checksums to the lockfile
This commit changes how lock files are encoded by checksums for each package in
the lockfile to the `[metadata]` section. The previous commit implemented the
ability to redirect sources, but the core assumption there was that a package
coming from two different locations was always the same. An inevitable case,
however, is that a source gets corrupted or, worse, ships a modified version of
a crate to introduce instability between two "mirrors".
The purpose of adding checksums will be to resolve this discrepancy. Each crate
coming from crates.io will now record its sha256 checksum in the lock file. When
a lock file already exists, the new checksum for a crate will be checked against
it, and if they differ compilation will be aborted. Currently only registry
crates will have sha256 checksums listed, all other sources do not have
checksums at this time.
The astute may notice that if the lock file format is changing, then a lock file
generated by a newer Cargo might be mangled by an older Cargo. In anticipation
of this, however, all Cargo versions published support a `[metadata]` section of
the lock file which is transparently carried forward if encountered. This means
that older Cargos compiling with a newer lock file will not verify checksums in
the lock file, but they will carry forward the checksum information and prevent
it from being removed.
There are, however, a few situations where problems may still arise:
1. If an older Cargo takes a newer lockfile (with checksums) and updates it with
a modified `Cargo.toml` (e.g. a package was added, removed, or updated), then
the `[metadata]` section will not be updated appropriately. This modification
would require a newer Cargo to come in and update the checksums for such a
modification.
2. Today Cargo can only calculate checksums for registry sources, but we may
eventually want to support other sources like git (or just straight-up path
sources). If future Cargo implements support for this sort of checksum, then
it's the same problem as above where older Cargos will not know how to keep
the checksum in sync
2016-02-03 19:04:07 +00:00
|
|
|
let registry = paths::home().join(".cargo/registry");
|
|
|
|
let backup = paths::root().join("registry-backup");
|
2016-02-05 23:14:17 +00:00
|
|
|
t!(fs::rename(®istry, &backup));
|
2014-12-19 21:43:21 +00:00
|
|
|
|
Add sha256 checksums to the lockfile
This commit changes how lock files are encoded by checksums for each package in
the lockfile to the `[metadata]` section. The previous commit implemented the
ability to redirect sources, but the core assumption there was that a package
coming from two different locations was always the same. An inevitable case,
however, is that a source gets corrupted or, worse, ships a modified version of
a crate to introduce instability between two "mirrors".
The purpose of adding checksums will be to resolve this discrepancy. Each crate
coming from crates.io will now record its sha256 checksum in the lock file. When
a lock file already exists, the new checksum for a crate will be checked against
it, and if they differ compilation will be aborted. Currently only registry
crates will have sha256 checksums listed, all other sources do not have
checksums at this time.
The astute may notice that if the lock file format is changing, then a lock file
generated by a newer Cargo might be mangled by an older Cargo. In anticipation
of this, however, all Cargo versions published support a `[metadata]` section of
the lock file which is transparently carried forward if encountered. This means
that older Cargos compiling with a newer lock file will not verify checksums in
the lock file, but they will carry forward the checksum information and prevent
it from being removed.
There are, however, a few situations where problems may still arise:
1. If an older Cargo takes a newer lockfile (with checksums) and updates it with
a modified `Cargo.toml` (e.g. a package was added, removed, or updated), then
the `[metadata]` section will not be updated appropriately. This modification
would require a newer Cargo to come in and update the checksums for such a
modification.
2. Today Cargo can only calculate checksums for registry sources, but we may
eventually want to support other sources like git (or just straight-up path
sources). If future Cargo implements support for this sort of checksum, then
it's the same problem as above where older Cargos will not know how to keep
the checksum in sync
2016-02-03 19:04:07 +00:00
|
|
|
// Generate a Cargo.lock with the newer version, and then move the old copy
|
|
|
|
// of the registry back into place.
|
2018-08-28 09:20:03 +00:00
|
|
|
let p2 = project()
|
|
|
|
.at("foo2")
|
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 = []
|
Add sha256 checksums to the lockfile
This commit changes how lock files are encoded by checksums for each package in
the lockfile to the `[metadata]` section. The previous commit implemented the
ability to redirect sources, but the core assumption there was that a package
coming from two different locations was always the same. An inevitable case,
however, is that a source gets corrupted or, worse, ships a modified version of
a crate to introduce instability between two "mirrors".
The purpose of adding checksums will be to resolve this discrepancy. Each crate
coming from crates.io will now record its sha256 checksum in the lock file. When
a lock file already exists, the new checksum for a crate will be checked against
it, and if they differ compilation will be aborted. Currently only registry
crates will have sha256 checksums listed, all other sources do not have
checksums at this time.
The astute may notice that if the lock file format is changing, then a lock file
generated by a newer Cargo might be mangled by an older Cargo. In anticipation
of this, however, all Cargo versions published support a `[metadata]` section of
the lock file which is transparently carried forward if encountered. This means
that older Cargos compiling with a newer lock file will not verify checksums in
the lock file, but they will carry forward the checksum information and prevent
it from being removed.
There are, however, a few situations where problems may still arise:
1. If an older Cargo takes a newer lockfile (with checksums) and updates it with
a modified `Cargo.toml` (e.g. a package was added, removed, or updated), then
the `[metadata]` section will not be updated appropriately. This modification
would require a newer Cargo to come in and update the checksums for such a
modification.
2. Today Cargo can only calculate checksums for registry sources, but we may
eventually want to support other sources like git (or just straight-up path
sources). If future Cargo implements support for this sort of checksum, then
it's the same problem as above where older Cargos will not know how to keep
the checksum in sync
2016-02-03 19:04:07 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
a = "0.1.1"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p2, "build").run();
|
2016-02-05 23:14:17 +00:00
|
|
|
registry.rm_rf();
|
|
|
|
t!(fs::rename(&backup, ®istry));
|
2018-03-14 15:17:44 +00:00
|
|
|
t!(fs::rename(
|
|
|
|
p2.root().join("Cargo.lock"),
|
|
|
|
p.root().join("Cargo.lock")
|
|
|
|
));
|
2014-12-19 21:43:21 +00:00
|
|
|
|
Add sha256 checksums to the lockfile
This commit changes how lock files are encoded by checksums for each package in
the lockfile to the `[metadata]` section. The previous commit implemented the
ability to redirect sources, but the core assumption there was that a package
coming from two different locations was always the same. An inevitable case,
however, is that a source gets corrupted or, worse, ships a modified version of
a crate to introduce instability between two "mirrors".
The purpose of adding checksums will be to resolve this discrepancy. Each crate
coming from crates.io will now record its sha256 checksum in the lock file. When
a lock file already exists, the new checksum for a crate will be checked against
it, and if they differ compilation will be aborted. Currently only registry
crates will have sha256 checksums listed, all other sources do not have
checksums at this time.
The astute may notice that if the lock file format is changing, then a lock file
generated by a newer Cargo might be mangled by an older Cargo. In anticipation
of this, however, all Cargo versions published support a `[metadata]` section of
the lock file which is transparently carried forward if encountered. This means
that older Cargos compiling with a newer lock file will not verify checksums in
the lock file, but they will carry forward the checksum information and prevent
it from being removed.
There are, however, a few situations where problems may still arise:
1. If an older Cargo takes a newer lockfile (with checksums) and updates it with
a modified `Cargo.toml` (e.g. a package was added, removed, or updated), then
the `[metadata]` section will not be updated appropriately. This modification
would require a newer Cargo to come in and update the checksums for such a
modification.
2. Today Cargo can only calculate checksums for registry sources, but we may
eventually want to support other sources like git (or just straight-up path
sources). If future Cargo implements support for this sort of checksum, then
it's the same problem as above where older Cargos will not know how to keep
the checksum in sync
2016-02-03 19:04:07 +00:00
|
|
|
// Finally, build the first project again (with our newer Cargo.lock) which
|
|
|
|
// should force an update of the old registry, download the new crate, and
|
|
|
|
// then build everything again.
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] [..]
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] a v0.1.1 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] a v0.1.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.5.0 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2016-05-12 15:23:53 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-02-24 00:14:34 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn fetch_downloads_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
fetch_downloads(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn fetch_downloads_git() {
|
|
|
|
fetch_downloads(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fetch_downloads(cargo: fn(&Project, &str) -> Execs) {
|
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 = []
|
2015-02-24 00:14:34 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
a = "0.1.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-02-24 00:14:34 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("a", "0.1.0").publish();
|
2015-02-24 00:14:34 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "fetch")
|
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] a v0.1.0 (registry [..])
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-04-30 01:42:52 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn update_transitive_dependency_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
update_transitive_dependency(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn update_transitive_dependency_git() {
|
|
|
|
update_transitive_dependency(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn update_transitive_dependency(cargo: fn(&Project, &str) -> Execs) {
|
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 = []
|
2015-04-30 01:42:52 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
a = "0.1.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-04-30 01:42:52 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("a", "0.1.0").dep("b", "*").publish();
|
|
|
|
Package::new("b", "0.1.0").publish();
|
2015-04-30 01:42:52 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "fetch").run();
|
2015-04-30 01:42:52 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("b", "0.1.1").publish();
|
2015-04-30 01:42:52 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "update -pb")
|
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
|
2016-02-03 18:54:07 +00:00
|
|
|
[UPDATING] b v0.1.0 -> v0.1.1
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2015-04-30 01:42:52 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
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 ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] b v0.1.1 (registry `dummy-registry`)
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] b v0.1.1
|
|
|
|
[COMPILING] a v0.1.0
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.5.0 ([..])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-07-27 22:40:02 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn update_backtracking_ok_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
update_backtracking_ok(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn update_backtracking_ok_git() {
|
|
|
|
update_backtracking_ok(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn update_backtracking_ok(cargo: fn(&Project, &str) -> Execs) {
|
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 = []
|
2015-07-27 22:40:02 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
webdriver = "0.1"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-07-27 22:40:02 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
Package::new("webdriver", "0.1.0")
|
|
|
|
.dep("hyper", "0.6")
|
|
|
|
.publish();
|
|
|
|
Package::new("hyper", "0.6.5")
|
|
|
|
.dep("openssl", "0.1")
|
|
|
|
.dep("cookie", "0.1")
|
|
|
|
.publish();
|
|
|
|
Package::new("cookie", "0.1.0")
|
|
|
|
.dep("openssl", "0.1")
|
|
|
|
.publish();
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("openssl", "0.1.0").publish();
|
2015-07-27 22:40:02 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "generate-lockfile").run();
|
2015-07-27 22:40:02 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("openssl", "0.1.1").publish();
|
2018-03-14 15:17:44 +00:00
|
|
|
Package::new("hyper", "0.6.6")
|
|
|
|
.dep("openssl", "0.1.1")
|
|
|
|
.dep("cookie", "0.1.0")
|
|
|
|
.publish();
|
2015-07-27 22:40:02 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "update -p hyper")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-06 05:21:47 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `[..]` index
|
2018-03-06 05:21:47 +00:00
|
|
|
[UPDATING] hyper v0.6.5 -> v0.6.6
|
|
|
|
[UPDATING] openssl v0.1.0 -> v0.1.1
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-09-15 23:02:37 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn update_multiple_packages_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
update_multiple_packages(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn update_multiple_packages_git() {
|
|
|
|
update_multiple_packages(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn update_multiple_packages(cargo: fn(&Project, &str) -> Execs) {
|
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 = []
|
2015-09-15 23:02:37 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
a = "*"
|
|
|
|
b = "*"
|
|
|
|
c = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-09-15 23:02:37 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("a", "0.1.0").publish();
|
|
|
|
Package::new("b", "0.1.0").publish();
|
|
|
|
Package::new("c", "0.1.0").publish();
|
2015-09-15 23:02:37 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "fetch").run();
|
2015-09-15 23:02:37 +00:00
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
Package::new("a", "0.1.1").publish();
|
|
|
|
Package::new("b", "0.1.1").publish();
|
|
|
|
Package::new("c", "0.1.1").publish();
|
2015-09-15 23:02:37 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "update -pa -pb")
|
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
|
2016-02-03 18:54:07 +00:00
|
|
|
[UPDATING] a v0.1.0 -> v0.1.1
|
|
|
|
[UPDATING] b v0.1.0 -> v0.1.1
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2015-09-15 23:02:37 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "update -pb -pc")
|
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
|
2016-02-03 18:54:07 +00:00
|
|
|
[UPDATING] c v0.1.0 -> v0.1.1
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-08-28 09:20:03 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2021-06-27 19:18:36 +00:00
|
|
|
.with_stderr_contains("[DOWNLOADED] a v0.1.1 (registry `dummy-registry`)")
|
|
|
|
.with_stderr_contains("[DOWNLOADED] b v0.1.1 (registry `dummy-registry`)")
|
|
|
|
.with_stderr_contains("[DOWNLOADED] c v0.1.1 (registry `dummy-registry`)")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr_contains("[COMPILING] a v0.1.1")
|
|
|
|
.with_stderr_contains("[COMPILING] b v0.1.1")
|
|
|
|
.with_stderr_contains("[COMPILING] c v0.1.1")
|
|
|
|
.with_stderr_contains("[COMPILING] foo v0.5.0 ([..])")
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-11-11 02:17:23 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn bundled_crate_in_registry_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
bundled_crate_in_registry(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn bundled_crate_in_registry_git() {
|
|
|
|
bundled_crate_in_registry(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bundled_crate_in_registry(cargo: fn(&Project, &str) -> Execs) {
|
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 = []
|
2015-11-11 02:17:23 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1"
|
|
|
|
baz = "0.1"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-11-11 02:17:23 +00:00
|
|
|
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
Package::new("baz", "0.1.0")
|
|
|
|
.dep("bar", "0.1.0")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "baz"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2015-11-11 02:17:23 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = { path = "bar", version = "0.1.0" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2015-11-11 02:17:23 +00:00
|
|
|
.file("bar/src/lib.rs", "")
|
|
|
|
.publish();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "run").run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn update_same_prefix_oh_my_how_was_this_a_bug_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
update_same_prefix_oh_my_how_was_this_a_bug(cargo_http);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-01-19 20:06:58 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn update_same_prefix_oh_my_how_was_this_a_bug_git() {
|
|
|
|
update_same_prefix_oh_my_how_was_this_a_bug(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn update_same_prefix_oh_my_how_was_this_a_bug(cargo: fn(&Project, &str) -> Execs) {
|
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 = "ugh"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
2016-01-19 20:06:58 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
foo = "0.1"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-01-19 20:06:58 +00:00
|
|
|
|
|
|
|
Package::new("foobar", "0.2.0").publish();
|
|
|
|
Package::new("foo", "0.1.0")
|
|
|
|
.dep("foobar", "0.2.0")
|
|
|
|
.publish();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "generate-lockfile").run();
|
|
|
|
cargo(&p, "update -pfoobar --precise=0.2.0").run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn use_semver_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
use_semver(cargo_http);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-01 22:02:23 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn use_semver_git() {
|
|
|
|
use_semver(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn use_semver(cargo: fn(&Project, &str) -> Execs) {
|
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.5.0"
|
|
|
|
authors = []
|
2016-02-01 22:02:23 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
foo = "1.2.3-alpha.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-01 22:02:23 +00:00
|
|
|
|
2016-02-22 05:02:20 +00:00
|
|
|
Package::new("foo", "1.2.3-alpha.0").publish();
|
2016-02-01 22:02:23 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-22 05:02:20 +00:00
|
|
|
|
2019-07-30 14:29:50 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn use_semver_package_incorrectly_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
use_semver_package_incorrectly(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn use_semver_package_incorrectly_git() {
|
|
|
|
use_semver_package_incorrectly(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn use_semver_package_incorrectly(cargo: fn(&Project, &str) -> Execs) {
|
2019-07-30 14:29:50 +00:00
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[workspace]
|
|
|
|
members = ["a", "b"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"a/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2019-07-30 14:29:50 +00:00
|
|
|
name = "a"
|
|
|
|
version = "0.1.1-alpha.0"
|
|
|
|
authors = []
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"b/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2019-07-30 14:29:50 +00:00
|
|
|
name = "b"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
a = { version = "^0.1", path = "../a" }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("a/src/main.rs", "fn main() {}")
|
|
|
|
.file("b/src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2019-07-30 14:29:50 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2021-07-11 18:06:20 +00:00
|
|
|
error: no matching package found
|
|
|
|
searched package name: `a`
|
2019-07-30 14:29:50 +00:00
|
|
|
prerelease package needs to be specified explicitly
|
|
|
|
a = { version = \"0.1.1-alpha.0\" }
|
2021-07-10 14:07:29 +00:00
|
|
|
location searched: [..]
|
2019-07-30 14:29:50 +00:00
|
|
|
required by package `b v0.1.0 ([..])`
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn only_download_relevant_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
only_download_relevant(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn only_download_relevant_git() {
|
|
|
|
only_download_relevant(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn only_download_relevant(cargo: fn(&Project, &str) -> Execs) {
|
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.5.0"
|
|
|
|
authors = []
|
2016-02-22 05:02:20 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[target.foo.dependencies]
|
|
|
|
foo = "*"
|
|
|
|
[dev-dependencies]
|
|
|
|
bar = "*"
|
|
|
|
[dependencies]
|
|
|
|
baz = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-22 05:02:20 +00:00
|
|
|
|
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
Package::new("baz", "0.1.0").publish();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
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] baz v0.1.0 ([..])
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] baz v0.1.0
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] bar v0.5.0 ([..])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-03-14 22:45:05 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn resolve_and_backtracking_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
resolve_and_backtracking(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn resolve_and_backtracking_git() {
|
|
|
|
resolve_and_backtracking(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn resolve_and_backtracking(cargo: fn(&Project, &str) -> Execs) {
|
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.5.0"
|
|
|
|
authors = []
|
2016-03-14 22:45:05 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
foo = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-03-14 22:45:05 +00:00
|
|
|
|
|
|
|
Package::new("foo", "0.1.1")
|
2018-03-14 15:17:44 +00:00
|
|
|
.feature_dep("bar", "0.1", &["a", "b"])
|
|
|
|
.publish();
|
2016-03-14 22:45:05 +00:00
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn upstream_warnings_on_extra_verbose_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
upstream_warnings_on_extra_verbose(cargo_http);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-04-12 21:55:19 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn upstream_warnings_on_extra_verbose_git() {
|
|
|
|
upstream_warnings_on_extra_verbose(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn upstream_warnings_on_extra_verbose(cargo: fn(&Project, &str) -> Execs) {
|
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.5.0"
|
|
|
|
authors = []
|
2016-04-12 21:55:19 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
foo = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-04-12 21:55:19 +00:00
|
|
|
|
|
|
|
Package::new("foo", "0.1.0")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file("src/lib.rs", "fn unused() {}")
|
|
|
|
.publish();
|
2016-04-12 21:55:19 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build -vv")
|
2022-06-23 20:08:08 +00:00
|
|
|
.with_stderr_contains("[WARNING] [..]unused[..]")
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2016-04-12 21:55:19 +00:00
|
|
|
}
|
2016-06-28 17:39:46 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn disallow_network_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-03-09 22:10:22 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "*"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
cargo_http(&p, "build --frozen")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..]
|
|
|
|
[ERROR] failed to get `foo` as a dependency of package `bar v0.5.0 ([..])`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to query replaced source registry `crates-io`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
attempting to make an HTTP request, but --frozen was specified
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn disallow_network_git() {
|
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.5.0"
|
|
|
|
authors = []
|
2016-06-28 17:39:46 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
foo = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-06-28 17:39:46 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo_stable(&p, "build --frozen")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2020-02-27 16:17:18 +00:00
|
|
|
[ERROR] failed to get `foo` as a dependency of package `bar v0.5.0 [..]`
|
2020-02-25 18:17:11 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to load source for dependency `foo`
|
2016-06-28 17:39:46 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
Unable to update registry [..]
|
|
|
|
|
|
|
|
Caused by:
|
2016-02-05 23:14:17 +00:00
|
|
|
attempting to make an HTTP request, but --frozen was specified
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-06-28 17:39:46 +00:00
|
|
|
}
|
2016-07-21 16:50:33 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn add_dep_dont_update_registry_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
add_dep_dont_update_registry(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn add_dep_dont_update_registry_git() {
|
|
|
|
add_dep_dont_update_registry(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_dep_dont_update_registry(cargo: fn(&Project, &str) -> Execs) {
|
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.5.0"
|
|
|
|
authors = []
|
2016-07-21 16:50:33 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
baz = { path = "baz" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("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.5.0"
|
|
|
|
authors = []
|
2016-07-21 16:50:33 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
remote = "0.3"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("baz/src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-07-21 16:50:33 +00:00
|
|
|
|
|
|
|
Package::new("remote", "0.3.4").publish();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
2016-07-21 16:50:33 +00:00
|
|
|
|
2020-04-17 04:10:11 +00:00
|
|
|
p.change_file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2016-07-21 16:50:33 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
baz = { path = "baz" }
|
|
|
|
remote = "0.3"
|
2020-04-17 04:10:11 +00:00
|
|
|
"#,
|
|
|
|
);
|
2016-07-21 16:50:33 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-07-21 16:50:33 +00:00
|
|
|
[COMPILING] bar v0.5.0 ([..])
|
|
|
|
[FINISHED] [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-07-21 16:50:33 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn bump_version_dont_update_registry_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
bump_version_dont_update_registry(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn bump_version_dont_update_registry_git() {
|
|
|
|
bump_version_dont_update_registry(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bump_version_dont_update_registry(cargo: fn(&Project, &str) -> Execs) {
|
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.5.0"
|
|
|
|
authors = []
|
2016-07-21 16:50:33 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
baz = { path = "baz" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("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.5.0"
|
|
|
|
authors = []
|
2016-07-21 16:50:33 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
remote = "0.3"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("baz/src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-07-21 16:50:33 +00:00
|
|
|
|
|
|
|
Package::new("remote", "0.3.4").publish();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
2016-07-21 16:50:33 +00:00
|
|
|
|
2020-04-17 04:10:11 +00:00
|
|
|
p.change_file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2016-07-21 16:50:33 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "0.6.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
baz = { path = "baz" }
|
2020-04-17 04:10:11 +00:00
|
|
|
"#,
|
|
|
|
);
|
2016-07-21 16:50:33 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-07-21 16:50:33 +00:00
|
|
|
[COMPILING] bar v0.6.0 ([..])
|
|
|
|
[FINISHED] [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-07-21 16:50:33 +00:00
|
|
|
}
|
2016-10-07 19:43:48 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn toml_lies_but_index_is_truth_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
toml_lies_but_index_is_truth(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn toml_lies_but_index_is_truth_git() {
|
|
|
|
toml_lies_but_index_is_truth(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn toml_lies_but_index_is_truth(cargo: fn(&Project, &str) -> Execs) {
|
2016-10-20 22:07:18 +00:00
|
|
|
Package::new("foo", "0.2.0").publish();
|
|
|
|
Package::new("bar", "0.3.0")
|
2018-03-14 15:17:44 +00:00
|
|
|
.dep("foo", "0.2.0")
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2016-10-20 22:07:18 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "0.3.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "extern crate foo;")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2016-10-20 22:07:18 +00:00
|
|
|
|
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.5.0"
|
|
|
|
authors = []
|
2016-10-20 22:07:18 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.3"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-10-20 22:07:18 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build -v").run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn vv_prints_warnings_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
vv_prints_warnings(cargo_http);
|
2016-10-20 22:07:18 +00:00
|
|
|
}
|
2017-03-13 17:15:36 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn vv_prints_warnings_git() {
|
|
|
|
vv_prints_warnings(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn vv_prints_warnings(cargo: fn(&Project, &str) -> Execs) {
|
2017-03-13 17:15:36 +00:00
|
|
|
Package::new("foo", "0.2.0")
|
2018-08-28 09:20:03 +00:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"#![deny(warnings)] fn foo() {} // unused function",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.publish();
|
2017-03-13 17:15: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",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "fo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
2017-03-13 17:15:36 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
foo = "0.2"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-03-13 17:15:36 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build -vv").run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn bad_and_or_malicious_packages_rejected_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
bad_and_or_malicious_packages_rejected(cargo_http);
|
2017-03-13 17:15:36 +00:00
|
|
|
}
|
2017-09-14 17:07:15 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn bad_and_or_malicious_packages_rejected_git() {
|
|
|
|
bad_and_or_malicious_packages_rejected(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bad_and_or_malicious_packages_rejected(cargo: fn(&Project, &str) -> Execs) {
|
2017-09-14 17:07:15 +00:00
|
|
|
Package::new("foo", "0.2.0")
|
2018-03-14 15:17:44 +00:00
|
|
|
.extra_file("foo-0.1.0/src/lib.rs", "")
|
|
|
|
.publish();
|
2017-09-14 17:07:15 +00:00
|
|
|
|
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 = "fo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
2017-09-14 17:07:15 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
foo = "0.2"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-09-14 17:07:15 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build -vv")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-09-14 17:07:15 +00:00
|
|
|
[UPDATING] [..]
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] [..]
|
2018-09-07 22:13:57 +00:00
|
|
|
error: failed to download [..]
|
2017-09-14 17:07:15 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to unpack [..]
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
[..] contains a file at \"foo-0.1.0/src/lib.rs\" which isn't under \"foo-0.2.0\"
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-09-14 17:07:15 +00:00
|
|
|
}
|
2018-05-26 02:12:53 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn git_init_templatedir_missing_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
git_init_templatedir_missing(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn git_init_templatedir_missing_git() {
|
|
|
|
git_init_templatedir_missing(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn git_init_templatedir_missing(cargo: fn(&Project, &str) -> Execs) {
|
2018-05-26 02:12:53 +00:00
|
|
|
Package::new("foo", "0.2.0").dep("bar", "*").publish();
|
|
|
|
Package::new("bar", "0.2.0").publish();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-05-26 02:12:53 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2018-05-26 02:12:53 +00:00
|
|
|
name = "fo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.2"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-05-26 02:12:53 +00:00
|
|
|
.build();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
2018-05-26 02:12:53 +00:00
|
|
|
|
|
|
|
remove_dir_all(paths::home().join(".cargo/registry")).unwrap();
|
2020-04-17 04:10:11 +00:00
|
|
|
fs::write(
|
|
|
|
paths::home().join(".gitconfig"),
|
|
|
|
r#"
|
2018-05-26 02:12:53 +00:00
|
|
|
[init]
|
|
|
|
templatedir = nowhere
|
2018-08-28 09:20:03 +00:00
|
|
|
"#,
|
2020-04-17 04:10:11 +00:00
|
|
|
)
|
|
|
|
.unwrap();
|
2018-08-28 09:20:03 +00:00
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
|
|
|
cargo(&p, "build").run();
|
2018-05-26 02:12:53 +00:00
|
|
|
}
|
2018-09-07 16:37:06 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn rename_deps_and_features_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
rename_deps_and_features(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn rename_deps_and_features_git() {
|
|
|
|
rename_deps_and_features(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn rename_deps_and_features(cargo: fn(&Project, &str) -> Execs) {
|
2018-09-07 16:37:06 +00:00
|
|
|
Package::new("foo", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub fn f1() {}")
|
|
|
|
.publish();
|
|
|
|
Package::new("foo", "0.2.0")
|
|
|
|
.file("src/lib.rs", "pub fn f2() {}")
|
|
|
|
.publish();
|
|
|
|
Package::new("bar", "0.2.0")
|
2018-12-08 11:19:47 +00:00
|
|
|
.add_dep(
|
|
|
|
Dependency::new("foo01", "0.1.0")
|
|
|
|
.package("foo")
|
|
|
|
.optional(true),
|
|
|
|
)
|
2018-09-07 16:37:06 +00:00
|
|
|
.add_dep(Dependency::new("foo02", "0.2.0").package("foo"))
|
|
|
|
.feature("another", &["foo01"])
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
|
|
|
extern crate foo02;
|
|
|
|
#[cfg(feature = "foo01")]
|
|
|
|
extern crate foo01;
|
|
|
|
|
|
|
|
pub fn foo() {
|
|
|
|
foo02::f2();
|
|
|
|
#[cfg(feature = "foo01")]
|
|
|
|
foo01::f1();
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2018-09-07 16:37:06 +00:00
|
|
|
name = "a"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.2"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-09-07 16:37:06 +00:00
|
|
|
"src/main.rs",
|
|
|
|
"
|
|
|
|
extern crate bar;
|
|
|
|
fn main() { bar::foo(); }
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
|
|
|
cargo(&p, "build --features bar/foo01").run();
|
|
|
|
cargo(&p, "build --features bar/another").run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn ignore_invalid_json_lines_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
ignore_invalid_json_lines(cargo_http);
|
2018-09-07 16:37:06 +00:00
|
|
|
}
|
2019-05-06 18:35:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn ignore_invalid_json_lines_git() {
|
|
|
|
ignore_invalid_json_lines(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn ignore_invalid_json_lines(cargo: fn(&Project, &str) -> Execs) {
|
2019-05-06 18:35:17 +00:00
|
|
|
Package::new("foo", "0.1.0").publish();
|
2019-05-07 12:08:29 +00:00
|
|
|
Package::new("foo", "0.1.1").invalid_json(true).publish();
|
2019-05-06 18:35:17 +00:00
|
|
|
Package::new("foo", "0.2.0").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2019-05-06 18:35:17 +00:00
|
|
|
name = "a"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = '0.1.0'
|
|
|
|
foo02 = { version = '0.2.0', package = 'foo' }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn readonly_registry_still_works_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
readonly_registry_still_works(cargo_http);
|
2019-05-06 18:35:17 +00:00
|
|
|
}
|
2019-05-14 14:30:10 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn readonly_registry_still_works_git() {
|
|
|
|
readonly_registry_still_works(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn readonly_registry_still_works(cargo: fn(&Project, &str) -> Execs) {
|
2019-05-14 14:30:10 +00:00
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2019-05-14 14:30:10 +00:00
|
|
|
name = "a"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = '0.1.0'
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "generate-lockfile").run();
|
|
|
|
cargo(&p, "fetch --locked").run();
|
2019-05-15 18:05:37 +00:00
|
|
|
chmod_readonly(&paths::home(), true);
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "build").run();
|
2019-05-15 18:05:37 +00:00
|
|
|
// make sure we un-readonly the files afterwards so "cargo clean" can remove them (#6934)
|
|
|
|
chmod_readonly(&paths::home(), false);
|
2019-05-14 14:30:10 +00:00
|
|
|
|
2019-05-15 18:05:37 +00:00
|
|
|
fn chmod_readonly(path: &Path, readonly: bool) {
|
2019-05-14 14:30:10 +00:00
|
|
|
for entry in t!(path.read_dir()) {
|
|
|
|
let entry = t!(entry);
|
|
|
|
let path = entry.path();
|
|
|
|
if t!(entry.file_type()).is_dir() {
|
2019-05-15 18:05:37 +00:00
|
|
|
chmod_readonly(&path, readonly);
|
2019-05-14 14:30:10 +00:00
|
|
|
} else {
|
2019-05-15 18:05:37 +00:00
|
|
|
set_readonly(&path, readonly);
|
2019-05-14 14:30:10 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-15 18:05:37 +00:00
|
|
|
set_readonly(path, readonly);
|
2019-05-14 14:30:10 +00:00
|
|
|
}
|
|
|
|
|
2019-05-15 18:05:37 +00:00
|
|
|
fn set_readonly(path: &Path, readonly: bool) {
|
2019-05-14 14:30:10 +00:00
|
|
|
let mut perms = t!(path.metadata()).permissions();
|
2019-05-15 18:05:37 +00:00
|
|
|
perms.set_readonly(readonly);
|
2019-05-14 14:30:10 +00:00
|
|
|
t!(fs::set_permissions(path, perms));
|
|
|
|
}
|
|
|
|
}
|
2020-03-06 17:56:58 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn registry_index_rejected_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
registry_index_rejected(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn registry_index_rejected_git() {
|
|
|
|
registry_index_rejected(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn registry_index_rejected(cargo: fn(&Project, &str) -> Execs) {
|
2020-03-06 17:56:58 +00:00
|
|
|
Package::new("dep", "0.1.0").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
|
|
|
[registry]
|
|
|
|
index = "https://example.com/"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
dep = "0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "check")
|
2020-03-06 17:56:58 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] failed to parse manifest at `[..]/foo/Cargo.toml`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
the `registry.index` config value is no longer supported
|
2020-06-25 15:25:52 +00:00
|
|
|
Use `[source]` replacement to alter the default index for crates.io.
|
2020-03-06 17:56:58 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "login")
|
2020-03-06 17:56:58 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] the `registry.index` config value is no longer supported
|
|
|
|
Use `[source]` replacement to alter the default index for crates.io.
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2020-11-05 22:24:34 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn package_lock_inside_package_is_overwritten() {
|
2022-06-09 03:04:33 +00:00
|
|
|
let registry = registry::init();
|
2020-11-05 22:24:34 +00:00
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-11-05 22:24:34 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = ">= 0.0.0"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("bar", "0.0.1")
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(".cargo-ok", "")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
p.cargo("build").run();
|
|
|
|
|
2022-06-09 03:04:33 +00:00
|
|
|
let id = SourceId::for_registry(registry.index_url()).unwrap();
|
2020-11-05 22:24:34 +00:00
|
|
|
let hash = cargo::util::hex::short_hash(&id);
|
|
|
|
let ok = cargo_home()
|
|
|
|
.join("registry")
|
|
|
|
.join("src")
|
|
|
|
.join(format!("-{}", hash))
|
|
|
|
.join("bar-0.0.1")
|
|
|
|
.join(".cargo-ok");
|
|
|
|
|
|
|
|
assert_eq!(ok.metadata().unwrap().len(), 2);
|
|
|
|
}
|
2021-02-10 18:58:07 +00:00
|
|
|
|
2022-08-26 00:12:25 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn package_lock_as_a_symlink_inside_package_is_overwritten() {
|
|
|
|
let registry = registry::init();
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-08-26 00:12:25 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = ">= 0.0.0"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("bar", "0.0.1")
|
|
|
|
.file("src/lib.rs", "pub fn f() {}")
|
|
|
|
.symlink(".cargo-ok", "src/lib.rs")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
p.cargo("build").run();
|
|
|
|
|
|
|
|
let id = SourceId::for_registry(registry.index_url()).unwrap();
|
|
|
|
let hash = cargo::util::hex::short_hash(&id);
|
|
|
|
let pkg_root = cargo_home()
|
|
|
|
.join("registry")
|
|
|
|
.join("src")
|
|
|
|
.join(format!("-{}", hash))
|
|
|
|
.join("bar-0.0.1");
|
|
|
|
let ok = pkg_root.join(".cargo-ok");
|
|
|
|
let librs = pkg_root.join("src/lib.rs");
|
|
|
|
|
|
|
|
// Is correctly overwritten and doesn't affect the file linked to
|
|
|
|
assert_eq!(ok.metadata().unwrap().len(), 2);
|
|
|
|
assert_eq!(fs::read_to_string(librs).unwrap(), "pub fn f() {}");
|
|
|
|
}
|
|
|
|
|
2021-02-10 18:58:07 +00:00
|
|
|
#[cargo_test]
|
2022-03-09 22:10:22 +00:00
|
|
|
fn ignores_unknown_index_version_http() {
|
|
|
|
let _server = setup_http();
|
|
|
|
ignores_unknown_index_version(cargo_http);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn ignores_unknown_index_version_git() {
|
|
|
|
ignores_unknown_index_version(cargo_stable);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn ignores_unknown_index_version(cargo: fn(&Project, &str) -> Execs) {
|
2021-02-10 18:58:07 +00:00
|
|
|
// If the version field is not understood, it is ignored.
|
|
|
|
Package::new("bar", "1.0.0").publish();
|
|
|
|
Package::new("bar", "1.0.1").schema_version(9999).publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "1.0"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-03-09 22:10:22 +00:00
|
|
|
cargo(&p, "tree")
|
2021-02-10 18:58:07 +00:00
|
|
|
.with_stdout(
|
|
|
|
"foo v0.1.0 [..]\n\
|
|
|
|
└── bar v1.0.0\n\
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2022-03-09 22:10:22 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn http_requires_z_flag() {
|
|
|
|
let _server = setup_http();
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-03-09 22:10:22 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = ">= 0.0.0"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
2022-06-17 16:20:00 +00:00
|
|
|
.with_stderr_contains(" usage of sparse registries requires `-Z sparse-registry`")
|
2022-03-09 22:10:22 +00:00
|
|
|
.run();
|
|
|
|
}
|
2022-05-24 02:39:23 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn http_requires_trailing_slash() {
|
2022-06-17 14:09:56 +00:00
|
|
|
cargo_process("-Z sparse-registry install bar --index sparse+https://index.crates.io")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["sparse-registry"])
|
2022-05-24 02:39:23 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr("[ERROR] registry url must end in a slash `/`: sparse+https://index.crates.io")
|
|
|
|
.run()
|
|
|
|
}
|
2022-08-21 10:21:41 +00:00
|
|
|
|
2022-09-14 16:34:17 +00:00
|
|
|
// Limit the test to debug builds so that `__CARGO_TEST_MAX_UNPACK_SIZE` will take affect.
|
|
|
|
#[cfg(debug_assertions)]
|
2022-08-21 10:21:41 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn reach_max_unpack_size() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-08-21 10:21:41 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = ">= 0.0.0"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("bar", "0.0.1").publish();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.env("__CARGO_TEST_MAX_UNPACK_SIZE", "8") // hit 8 bytes limit and boom!
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `dummy-registry`)
|
|
|
|
[ERROR] failed to download replaced source registry `crates-io`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to unpack package `bar v0.0.1 (registry `dummy-registry`)`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to iterate over archive
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
maximum limit reached when reading
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2022-09-09 20:58:58 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn sparse_retry() {
|
|
|
|
let fail_count = Mutex::new(0);
|
|
|
|
let _registry = RegistryBuilder::new()
|
|
|
|
.http_index()
|
|
|
|
.add_responder("/index/3/b/bar", move |req, server| {
|
|
|
|
let mut fail_count = fail_count.lock().unwrap();
|
|
|
|
if *fail_count < 2 {
|
|
|
|
*fail_count += 1;
|
|
|
|
server.internal_server_error(req)
|
|
|
|
} else {
|
|
|
|
server.index(req)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = ">= 0.0.0"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("bar", "0.0.1").publish();
|
|
|
|
|
|
|
|
cargo_http(&p, "build")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
warning: spurious network error (2 tries remaining): failed to get successful HTTP response from `[..]`, got 500
|
|
|
|
body:
|
|
|
|
internal server error
|
|
|
|
warning: spurious network error (1 tries remaining): failed to get successful HTTP response from `[..]`, got 500
|
|
|
|
body:
|
|
|
|
internal server error
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `dummy-registry`)
|
|
|
|
[COMPILING] bar v0.0.1
|
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|