2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for alternative registries.
|
|
|
|
|
2022-09-10 03:30:34 +00:00
|
|
|
use cargo_test_support::compare::assert_match_exact;
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::publish::validate_alt_upload;
|
2022-06-09 03:04:33 +00:00
|
|
|
use cargo_test_support::registry::{self, Package, RegistryBuilder};
|
2022-08-31 05:53:47 +00:00
|
|
|
use cargo_test_support::{basic_manifest, paths, project};
|
2020-04-17 04:10:11 +00:00
|
|
|
use std::fs;
|
2017-08-30 05:55:31 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-08-30 05:55:31 +00:00
|
|
|
fn depend_on_alt_registry() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
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 = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-24 20:24:12 +00:00
|
|
|
.build();
|
2017-08-30 05:55:31 +00:00
|
|
|
|
|
|
|
Package::new("bar", "0.0.1").alternative(true).publish();
|
|
|
|
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check")
|
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] `alternative` 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 `alternative`)
|
2023-02-03 20:59:17 +00:00
|
|
|
[CHECKING] bar v0.0.1 (registry `alternative`)
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2017-08-30 05:55:31 +00:00
|
|
|
",
|
2021-06-27 19:18:36 +00:00
|
|
|
)
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2017-08-30 05:55:31 +00:00
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("clean").run();
|
2017-08-30 05:55:31 +00:00
|
|
|
|
|
|
|
// Don't download a second time
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check")
|
2018-08-29 17:56:48 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2023-02-03 20:59:17 +00:00
|
|
|
[CHECKING] bar v0.0.1 (registry `alternative`)
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2017-08-30 05:55:31 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-08-30 05:55:31 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-11-08 05:42:48 +00:00
|
|
|
fn depend_on_alt_registry_depends_on_same_registry_no_index() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
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 = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-24 20:24:12 +00:00
|
|
|
.build();
|
2017-10-06 22:34:00 +00:00
|
|
|
|
|
|
|
Package::new("baz", "0.0.1").alternative(true).publish();
|
2018-03-14 15:17:44 +00:00
|
|
|
Package::new("bar", "0.0.1")
|
2018-12-30 04:46:15 +00:00
|
|
|
.registry_dep("baz", "0.0.1")
|
2018-03-14 15:17:44 +00:00
|
|
|
.alternative(true)
|
|
|
|
.publish();
|
|
|
|
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check")
|
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] `alternative` index
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `alternative`)
|
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `alternative`)
|
2023-02-03 20:59:17 +00:00
|
|
|
[CHECKING] baz v0.0.1 (registry `alternative`)
|
|
|
|
[CHECKING] bar v0.0.1 (registry `alternative`)
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2017-10-06 22:34:00 +00:00
|
|
|
",
|
2021-06-27 19:18:36 +00:00
|
|
|
)
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2017-10-06 22:34:00 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-11-08 05:42:48 +00:00
|
|
|
fn depend_on_alt_registry_depends_on_same_registry() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
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 = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-11-08 05:42:48 +00:00
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("baz", "0.0.1").alternative(true).publish();
|
2018-03-14 15:17:44 +00:00
|
|
|
Package::new("bar", "0.0.1")
|
2018-12-30 04:46:15 +00:00
|
|
|
.registry_dep("baz", "0.0.1")
|
2018-03-14 15:17:44 +00:00
|
|
|
.alternative(true)
|
|
|
|
.publish();
|
|
|
|
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check")
|
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] `alternative` index
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `alternative`)
|
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `alternative`)
|
2023-02-03 20:59:17 +00:00
|
|
|
[CHECKING] baz v0.0.1 (registry `alternative`)
|
|
|
|
[CHECKING] bar v0.0.1 (registry `alternative`)
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2017-11-08 05:42:48 +00:00
|
|
|
",
|
2021-06-27 19:18:36 +00:00
|
|
|
)
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2017-11-08 05:42:48 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-10-06 22:34:00 +00:00
|
|
|
fn depend_on_alt_registry_depends_on_crates_io() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
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 = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-24 20:24:12 +00:00
|
|
|
.build();
|
2017-10-06 22:34:00 +00:00
|
|
|
|
|
|
|
Package::new("baz", "0.0.1").publish();
|
2018-03-14 15:17:44 +00:00
|
|
|
Package::new("bar", "0.0.1")
|
2018-12-30 04:46:15 +00:00
|
|
|
.dep("baz", "0.0.1")
|
2018-03-14 15:17:44 +00:00
|
|
|
.alternative(true)
|
|
|
|
.publish();
|
|
|
|
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check")
|
2021-06-27 19:18:36 +00:00
|
|
|
.with_stderr_unordered(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `alternative` index
|
|
|
|
[UPDATING] `dummy-registry` index
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] baz v0.0.1 (registry `dummy-registry`)
|
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `alternative`)
|
2023-02-03 20:59:17 +00:00
|
|
|
[CHECKING] baz v0.0.1
|
|
|
|
[CHECKING] bar v0.0.1 (registry `alternative`)
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2017-10-06 22:34:00 +00:00
|
|
|
",
|
2021-06-27 19:18:36 +00:00
|
|
|
)
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2017-10-06 22:34:00 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-01-20 06:31:11 +00:00
|
|
|
fn registry_and_path_dep_works() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
2018-01-20 06:31:11 +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 = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "bar"
|
|
|
|
registry = "alternative"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
2018-01-20 06:31:11 +00:00
|
|
|
.file("bar/src/lib.rs", "")
|
2017-10-24 20:24:12 +00:00
|
|
|
.build();
|
2017-08-30 05:55:31 +00:00
|
|
|
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check")
|
2018-08-29 17:56:48 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2023-02-03 20:59:17 +00:00
|
|
|
[CHECKING] bar v0.0.1 ([CWD]/bar)
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2018-05-02 12:52:40 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
2018-01-20 06:31:11 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-08-30 05:55:31 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-08-30 05:55:31 +00:00
|
|
|
fn registry_incompatible_with_git() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
2018-01-20 06:31:11 +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 = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
git = ""
|
|
|
|
registry = "alternative"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-24 20:24:12 +00:00
|
|
|
.build();
|
2017-08-30 05:55:31 +00:00
|
|
|
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check")
|
2019-02-11 23:16:13 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
|
|
|
" dependency (bar) specification is ambiguous. \
|
|
|
|
Only one of `git` or `registry` is allowed.",
|
|
|
|
)
|
|
|
|
.run();
|
2017-08-30 05:55:31 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-11-06 20:37:40 +00:00
|
|
|
fn cannot_publish_to_crates_io_with_registry_dependency() {
|
2022-08-31 05:53:47 +00:00
|
|
|
let crates_io = registry::init();
|
|
|
|
let _alternative = RegistryBuilder::new().alternative().build();
|
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 = []
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-11-06 20:37:40 +00:00
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("bar", "0.0.1").alternative(true).publish();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(crates_io.index_url())
|
2019-01-05 18:56:49 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains("[ERROR] crates cannot be published to crates.io[..]")
|
|
|
|
.run();
|
|
|
|
|
2022-08-31 05:53:47 +00:00
|
|
|
p.cargo("publish")
|
|
|
|
.replace_crates_io(crates_io.index_url())
|
|
|
|
.arg("--token")
|
|
|
|
.arg(crates_io.token())
|
|
|
|
.arg("--index")
|
|
|
|
.arg(crates_io.index_url().as_str())
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
2018-12-29 01:47:50 +00:00
|
|
|
.with_stderr_contains("[ERROR] crates cannot be published to crates.io[..]")
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2017-11-06 20:37:40 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-11-01 22:14:33 +00:00
|
|
|
fn publish_with_registry_dependency() {
|
2023-02-15 02:12:34 +00:00
|
|
|
let _reg = RegistryBuilder::new()
|
|
|
|
.http_api()
|
|
|
|
.http_index()
|
|
|
|
.alternative()
|
|
|
|
.build();
|
|
|
|
|
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 = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-24 20:24:12 +00:00
|
|
|
.build();
|
2017-08-30 05:55:31 +00:00
|
|
|
|
|
|
|
Package::new("bar", "0.0.1").alternative(true).publish();
|
|
|
|
|
2023-02-15 02:12:34 +00:00
|
|
|
p.cargo("publish --registry alternative")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `alternative` index
|
|
|
|
[WARNING] [..]
|
|
|
|
[..]
|
|
|
|
[PACKAGING] foo v0.0.1 [..]
|
|
|
|
[UPDATING] `alternative` index
|
|
|
|
[VERIFYING] foo v0.0.1 [..]
|
|
|
|
[DOWNLOADING] [..]
|
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `alternative`)
|
|
|
|
[COMPILING] bar v0.0.1 (registry `alternative`)
|
|
|
|
[COMPILING] foo v0.0.1 [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
[PACKAGED] [..]
|
|
|
|
[UPLOADING] foo v0.0.1 [..]
|
2023-03-15 15:50:11 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `alternative`
|
|
|
|
note: Waiting for `foo v0.0.1` to be available at registry `alternative`.
|
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
|
|
|
[PUBLISHED] foo v0.0.1 at registry `alternative`
|
2023-02-15 02:12:34 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
2018-12-30 04:46:15 +00:00
|
|
|
|
|
|
|
validate_alt_upload(
|
|
|
|
r#"{
|
|
|
|
"authors": [],
|
|
|
|
"badges": {},
|
|
|
|
"categories": [],
|
|
|
|
"deps": [
|
|
|
|
{
|
|
|
|
"default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"kind": "normal",
|
|
|
|
"name": "bar",
|
|
|
|
"optional": false,
|
|
|
|
"target": null,
|
|
|
|
"version_req": "^0.0.1"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"description": null,
|
|
|
|
"documentation": null,
|
|
|
|
"features": {},
|
|
|
|
"homepage": null,
|
|
|
|
"keywords": [],
|
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"links": null,
|
|
|
|
"name": "foo",
|
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
|
|
|
"repository": null,
|
2020-10-01 09:22:49 +00:00
|
|
|
"homepage": null,
|
|
|
|
"documentation": null,
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"vers": "0.0.1"
|
|
|
|
}"#,
|
|
|
|
"foo-0.0.1.crate",
|
2019-06-10 19:38:51 +00:00
|
|
|
&["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
|
2018-12-30 04:46:15 +00:00
|
|
|
);
|
2017-08-30 05:55:31 +00:00
|
|
|
}
|
2017-10-21 19:10:25 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-10-21 19:10:25 +00:00
|
|
|
fn alt_registry_and_crates_io_deps() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
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 = []
|
2017-10-21 19:10:25 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
crates_io_dep = "0.0.1"
|
2017-10-21 19:10:25 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.alt_reg_dep]
|
|
|
|
version = "0.1.0"
|
|
|
|
registry = "alternative"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-10-24 20:24:12 +00:00
|
|
|
.build();
|
2017-10-21 19:10:25 +00:00
|
|
|
|
|
|
|
Package::new("crates_io_dep", "0.0.1").publish();
|
2018-03-14 15:17:44 +00:00
|
|
|
Package::new("alt_reg_dep", "0.1.0")
|
|
|
|
.alternative(true)
|
|
|
|
.publish();
|
|
|
|
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check")
|
2021-06-27 19:18:36 +00:00
|
|
|
.with_stderr_unordered(
|
|
|
|
"\
|
|
|
|
[UPDATING] `alternative` index
|
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] crates_io_dep v0.0.1 (registry `dummy-registry`)
|
|
|
|
[DOWNLOADED] alt_reg_dep v0.1.0 (registry `alternative`)
|
2023-02-03 20:59:17 +00:00
|
|
|
[CHECKING] alt_reg_dep v0.1.0 (registry `alternative`)
|
|
|
|
[CHECKING] crates_io_dep v0.0.1
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2021-06-27 19:18:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
|
|
|
",
|
|
|
|
)
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2017-10-21 19:10:25 +00:00
|
|
|
}
|
2017-10-30 14:29:37 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-10-30 14:29:37 +00:00
|
|
|
fn block_publish_due_to_no_token() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
2020-03-06 23:05:12 +00:00
|
|
|
let p = project().file("src/lib.rs", "").build();
|
2017-10-30 14:29:37 +00:00
|
|
|
|
2023-01-03 21:40:58 +00:00
|
|
|
fs::remove_file(paths::home().join(".cargo/credentials.toml")).unwrap();
|
2019-01-11 23:56:46 +00:00
|
|
|
|
2017-10-30 14:29:37 +00:00
|
|
|
// Now perform the actual publish
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("publish --registry alternative")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
2022-10-31 16:44:01 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `alternative` index
|
|
|
|
error: no token found for `alternative`, please run `cargo login --registry alternative`
|
2023-04-03 16:27:11 +00:00
|
|
|
or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn cargo_registries_crates_io_protocol() {
|
|
|
|
let _ = RegistryBuilder::new()
|
|
|
|
.no_configure_token()
|
|
|
|
.alternative()
|
|
|
|
.build();
|
|
|
|
// Should not produce a warning due to the registries.crates-io.protocol = 'sparse' configuration
|
|
|
|
let p = project()
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(
|
|
|
|
".cargo/config.toml",
|
|
|
|
"[registries.crates-io]
|
|
|
|
protocol = 'sparse'",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --registry alternative")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `alternative` index
|
|
|
|
error: no token found for `alternative`, please run `cargo login --registry alternative`
|
2022-10-31 16:44:01 +00:00
|
|
|
or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN",
|
2020-03-06 23:05:12 +00:00
|
|
|
)
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2017-10-30 14:29:37 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-10-30 14:29:37 +00:00
|
|
|
fn publish_to_alt_registry() {
|
2023-02-15 02:12:34 +00:00
|
|
|
let _reg = RegistryBuilder::new()
|
|
|
|
.http_api()
|
|
|
|
.http_index()
|
2023-02-19 05:26:59 +00:00
|
|
|
.alternative()
|
2023-02-15 02:12:34 +00:00
|
|
|
.build();
|
2017-10-30 14:29:37 +00:00
|
|
|
|
2023-02-15 02:12:34 +00:00
|
|
|
let p = project().file("src/main.rs", "fn main() {}").build();
|
2017-10-30 14:29:37 +00:00
|
|
|
|
|
|
|
// Now perform the actual publish
|
2023-02-15 02:12:34 +00:00
|
|
|
p.cargo("publish --registry alternative")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `alternative` index
|
|
|
|
[WARNING] [..]
|
|
|
|
[..]
|
|
|
|
[PACKAGING] foo v0.0.1 [..]
|
|
|
|
[VERIFYING] foo v0.0.1 [..]
|
|
|
|
[COMPILING] foo v0.0.1 [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
[PACKAGED] [..]
|
|
|
|
[UPLOADING] foo v0.0.1 [..]
|
2023-03-15 15:50:11 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `alternative`
|
|
|
|
note: Waiting for `foo v0.0.1` to be available at registry `alternative`.
|
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
|
|
|
[PUBLISHED] foo v0.0.1 at registry `alternative`
|
2023-02-15 02:12:34 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
2023-03-04 01:11:37 +00:00
|
|
|
|
|
|
|
validate_alt_upload(
|
|
|
|
r#"{
|
|
|
|
"authors": [],
|
|
|
|
"badges": {},
|
|
|
|
"categories": [],
|
|
|
|
"deps": [],
|
|
|
|
"description": null,
|
|
|
|
"documentation": null,
|
|
|
|
"features": {},
|
|
|
|
"homepage": null,
|
|
|
|
"keywords": [],
|
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"links": null,
|
|
|
|
"name": "foo",
|
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
|
|
|
"repository": null,
|
|
|
|
"homepage": null,
|
|
|
|
"documentation": null,
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": null,
|
2023-03-04 01:11:37 +00:00
|
|
|
"vers": "0.0.1"
|
|
|
|
}"#,
|
|
|
|
"foo-0.0.1.crate",
|
|
|
|
&["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
|
|
|
|
);
|
2017-10-30 14:29:37 +00:00
|
|
|
}
|
2017-11-01 22:14:33 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-11-01 22:14:33 +00:00
|
|
|
fn publish_with_crates_io_dep() {
|
2023-02-19 03:59:17 +00:00
|
|
|
// crates.io registry.
|
|
|
|
let _dummy_reg = registry::init();
|
|
|
|
// Alternative registry.
|
|
|
|
let _alt_reg = RegistryBuilder::new()
|
|
|
|
.http_api()
|
|
|
|
.http_index()
|
2023-02-19 05:26:59 +00:00
|
|
|
.alternative()
|
2023-02-19 03:59:17 +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",
|
|
|
|
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 = ["me"]
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-11-01 22:14:33 +00:00
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("bar", "0.0.1").publish();
|
|
|
|
|
2023-02-19 03:59:17 +00:00
|
|
|
p.cargo("publish --registry alternative")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `alternative` index
|
|
|
|
[WARNING] [..]
|
|
|
|
[..]
|
|
|
|
[PACKAGING] foo v0.0.1 [..]
|
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
[VERIFYING] foo v0.0.1 [..]
|
|
|
|
[DOWNLOADING] [..]
|
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `dummy-registry`)
|
|
|
|
[COMPILING] bar v0.0.1
|
|
|
|
[COMPILING] foo v0.0.1 [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
[PACKAGED] [..]
|
|
|
|
[UPLOADING] foo v0.0.1 [..]
|
2023-03-15 15:50:11 +00:00
|
|
|
[UPLOADED] foo v0.0.1 to registry `alternative`
|
|
|
|
note: Waiting for `foo v0.0.1` to be available at registry `alternative`.
|
|
|
|
You may press ctrl-c to skip waiting; the crate should be available shortly.
|
|
|
|
[PUBLISHED] foo v0.0.1 at registry `alternative`
|
2023-02-19 03:59:17 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
2018-12-30 04:46:15 +00:00
|
|
|
|
|
|
|
validate_alt_upload(
|
|
|
|
r#"{
|
|
|
|
"authors": ["me"],
|
|
|
|
"badges": {},
|
|
|
|
"categories": [],
|
|
|
|
"deps": [
|
|
|
|
{
|
|
|
|
"default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"kind": "normal",
|
|
|
|
"name": "bar",
|
|
|
|
"optional": false,
|
|
|
|
"registry": "https://github.com/rust-lang/crates.io-index",
|
|
|
|
"target": null,
|
|
|
|
"version_req": "^0.0.1"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"description": "foo",
|
|
|
|
"documentation": null,
|
|
|
|
"features": {},
|
|
|
|
"homepage": null,
|
|
|
|
"keywords": [],
|
|
|
|
"license": "MIT",
|
|
|
|
"license_file": null,
|
|
|
|
"links": null,
|
|
|
|
"name": "foo",
|
|
|
|
"readme": null,
|
|
|
|
"readme_file": null,
|
|
|
|
"repository": null,
|
2020-10-01 09:22:49 +00:00
|
|
|
"homepage": null,
|
|
|
|
"documentation": null,
|
2023-03-24 20:46:59 +00:00
|
|
|
"rust_version": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"vers": "0.0.1"
|
|
|
|
}"#,
|
|
|
|
"foo-0.0.1.crate",
|
2019-06-10 19:38:51 +00:00
|
|
|
&["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
|
2018-12-30 04:46:15 +00:00
|
|
|
);
|
2017-11-01 22:14:33 +00:00
|
|
|
}
|
2018-01-24 20:54:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-04-27 23:01:43 +00:00
|
|
|
fn passwords_in_registries_index_url_forbidden() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
2018-01-24 20:54:17 +00:00
|
|
|
|
2024-01-26 19:40:46 +00:00
|
|
|
let config = paths::home().join(".cargo/config.toml");
|
2018-01-24 20:54:17 +00:00
|
|
|
|
2020-04-17 04:10:11 +00:00
|
|
|
fs::write(
|
|
|
|
config,
|
|
|
|
r#"
|
2018-01-24 20:54:17 +00:00
|
|
|
[registries.alternative]
|
|
|
|
index = "ssh://git:secret@foobar.com"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2020-04-17 04:10:11 +00:00
|
|
|
)
|
|
|
|
.unwrap();
|
2018-01-24 20:54:17 +00:00
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
let p = project().file("src/main.rs", "fn main() {}").build();
|
2018-01-24 20:54:17 +00:00
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("publish --registry alternative")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
2020-05-25 18:17:28 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
2024-01-26 19:40:46 +00:00
|
|
|
error: invalid index URL for registry `alternative` defined in [..]/home/.cargo/config.toml
|
2020-05-25 18:17:28 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
registry URLs may not contain passwords
|
|
|
|
",
|
|
|
|
)
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2018-01-24 20:54:17 +00:00
|
|
|
}
|
2018-12-18 04:35:50 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-12-18 04:35:50 +00:00
|
|
|
fn patch_alt_reg() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
2018-12-18 04:35:50 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2018-12-18 04:35:50 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = { version = "0.1.0", registry = "alternative" }
|
2018-12-18 04:35:50 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[patch.alternative]
|
|
|
|
bar = { path = "bar" }
|
|
|
|
"#,
|
2018-12-18 04:35:50 +00:00
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"
|
|
|
|
extern crate bar;
|
|
|
|
pub fn f() { bar::bar(); }
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
|
|
|
.file("bar/src/lib.rs", "pub fn bar() {}")
|
|
|
|
.build();
|
|
|
|
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check")
|
2018-12-18 04:35:50 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `alternative` index
|
2023-02-03 20:59:17 +00:00
|
|
|
[CHECKING] bar v0.1.0 ([CWD]/bar)
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2018-12-18 04:35:50 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2018-12-20 04:33:57 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-12-20 04:33:57 +00:00
|
|
|
fn bad_registry_name() {
|
|
|
|
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 = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "bad name"
|
|
|
|
"#,
|
2018-12-20 04:33:57 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2023-12-14 22:28:05 +00:00
|
|
|
[ERROR] invalid character ` ` in registry name: `bad name`, characters must be Unicode XID characters (numbers, `-`, `_`, or most letters)
|
2023-12-13 17:37:08 +00:00
|
|
|
|
|
|
|
|
2023-12-14 22:28:05 +00:00
|
|
|
--> Cargo.toml:7:17
|
|
|
|
|
|
|
|
|
7 | [dependencies.bar]
|
|
|
|
| _________________^
|
|
|
|
8 | | version = \"0.0.1\"
|
|
|
|
9 | | registry = \"bad name\"
|
|
|
|
| |_____________________________________^
|
|
|
|
|
|
2023-12-13 17:37:08 +00:00
|
|
|
",
|
2018-12-20 04:33:57 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
for cmd in &[
|
2019-04-05 19:55:01 +00:00
|
|
|
"init",
|
|
|
|
"install foo",
|
|
|
|
"login",
|
|
|
|
"owner",
|
|
|
|
"publish",
|
|
|
|
"search",
|
2022-04-18 17:03:01 +00:00
|
|
|
"yank --version 0.0.1",
|
2018-12-20 04:33:57 +00:00
|
|
|
] {
|
|
|
|
p.cargo(cmd)
|
|
|
|
.arg("--registry")
|
|
|
|
.arg("bad name")
|
|
|
|
.with_status(101)
|
2020-03-02 22:26:21 +00:00
|
|
|
.with_stderr("[ERROR] invalid character ` ` in registry name: `bad name`, [..]")
|
2018-12-20 04:33:57 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
}
|
2018-12-20 01:40:01 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-12-20 01:40:01 +00:00
|
|
|
fn no_api() {
|
2022-06-09 03:04:33 +00:00
|
|
|
let _registry = RegistryBuilder::new().alternative().no_api().build();
|
2018-12-20 01:40:01 +00:00
|
|
|
Package::new("bar", "0.0.1").alternative(true).publish();
|
|
|
|
|
|
|
|
// First check that a dependency works.
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
|
|
|
"#,
|
2018-12-20 01:40:01 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check")
|
2021-06-27 19:18:36 +00:00
|
|
|
.with_stderr(
|
2018-12-20 01:40:01 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `alternative` index
|
2018-12-20 01:40:01 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `alternative`)
|
2023-02-03 20:59:17 +00:00
|
|
|
[CHECKING] bar v0.0.1 (registry `alternative`)
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2018-12-20 01:40:01 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
|
|
|
",
|
2021-06-27 19:18:36 +00:00
|
|
|
)
|
2018-12-20 01:40:01 +00:00
|
|
|
.run();
|
|
|
|
|
|
|
|
// Check all of the API commands.
|
2021-06-27 19:18:36 +00:00
|
|
|
let err = "[ERROR] registry `alternative` does not support API commands";
|
2018-12-20 01:40:01 +00:00
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("login --registry alternative TOKEN")
|
2018-12-20 01:40:01 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(&err)
|
|
|
|
.run();
|
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("publish --registry alternative")
|
2018-12-20 01:40:01 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(&err)
|
|
|
|
.run();
|
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("search --registry alternative")
|
2018-12-20 01:40:01 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(&err)
|
|
|
|
.run();
|
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("owner --registry alternative --list")
|
2018-12-20 01:40:01 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(&err)
|
|
|
|
.run();
|
|
|
|
|
2022-04-18 17:03:01 +00:00
|
|
|
p.cargo("yank --registry alternative --version=0.0.1 bar")
|
2018-12-20 01:40:01 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(&err)
|
|
|
|
.run();
|
|
|
|
|
2022-04-18 17:03:01 +00:00
|
|
|
p.cargo("yank --registry alternative --version=0.0.1 bar")
|
2018-12-20 01:40:01 +00:00
|
|
|
.with_stderr_contains(&err)
|
|
|
|
.with_status(101)
|
|
|
|
.run();
|
|
|
|
}
|
2018-12-30 04:46:15 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-12-30 04:46:15 +00:00
|
|
|
fn alt_reg_metadata() {
|
|
|
|
// Check for "registry" entries in `cargo metadata` with alternative registries.
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
2018-12-30 04:46:15 +00:00
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
altdep = { version = "0.0.1", registry = "alternative" }
|
|
|
|
iodep = { version = "0.0.1" }
|
|
|
|
"#,
|
2018-12-30 04:46:15 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("bar", "0.0.1").publish();
|
|
|
|
Package::new("altdep", "0.0.1")
|
|
|
|
.dep("bar", "0.0.1")
|
|
|
|
.alternative(true)
|
|
|
|
.publish();
|
|
|
|
Package::new("altdep2", "0.0.1").alternative(true).publish();
|
|
|
|
Package::new("iodep", "0.0.1")
|
|
|
|
.registry_dep("altdep2", "0.0.1")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
// The important thing to check here is the "registry" value in `deps`.
|
|
|
|
// They should be:
|
|
|
|
// foo -> altdep: alternative-registry
|
|
|
|
// foo -> iodep: null (because it is in crates.io)
|
|
|
|
// altdep -> bar: null (because it is in crates.io)
|
|
|
|
// iodep -> altdep2: alternative-registry
|
|
|
|
p.cargo("metadata --format-version=1 --no-deps")
|
|
|
|
.with_json(
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"packages": [
|
|
|
|
{
|
|
|
|
"name": "foo",
|
|
|
|
"version": "0.0.1",
|
2023-11-02 16:37:14 +00:00
|
|
|
"id": "path+file:[..]/foo#0.0.1",
|
2018-12-30 04:46:15 +00:00
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
|
|
|
"source": null,
|
|
|
|
"dependencies": [
|
|
|
|
{
|
|
|
|
"name": "altdep",
|
|
|
|
"source": "registry+file:[..]/alternative-registry",
|
|
|
|
"req": "^0.0.1",
|
|
|
|
"kind": null,
|
|
|
|
"rename": null,
|
|
|
|
"optional": false,
|
|
|
|
"uses_default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"target": null,
|
|
|
|
"registry": "file:[..]/alternative-registry"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "iodep",
|
|
|
|
"source": "registry+https://github.com/rust-lang/crates.io-index",
|
|
|
|
"req": "^0.0.1",
|
|
|
|
"kind": null,
|
|
|
|
"rename": null,
|
|
|
|
"optional": false,
|
|
|
|
"uses_default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"target": null,
|
|
|
|
"registry": null
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"targets": "{...}",
|
|
|
|
"features": {},
|
|
|
|
"manifest_path": "[..]/foo/Cargo.toml",
|
|
|
|
"metadata": null,
|
2019-09-11 18:46:12 +00:00
|
|
|
"publish": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"authors": [],
|
|
|
|
"categories": [],
|
2021-06-07 06:17:34 +00:00
|
|
|
"default_run": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
2021-10-08 17:00:39 +00:00
|
|
|
"rust_version": null,
|
2020-10-01 09:22:49 +00:00
|
|
|
"homepage": null,
|
|
|
|
"documentation": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"workspace_members": [
|
2023-11-02 16:37:14 +00:00
|
|
|
"path+file:[..]/foo#0.0.1"
|
2018-12-30 04:46:15 +00:00
|
|
|
],
|
2023-05-03 08:37:37 +00:00
|
|
|
"workspace_default_members": [
|
2023-11-02 16:37:14 +00:00
|
|
|
"path+file:[..]/foo#0.0.1"
|
2023-05-03 08:37:37 +00:00
|
|
|
],
|
2018-12-30 04:46:15 +00:00
|
|
|
"resolve": null,
|
|
|
|
"target_directory": "[..]/foo/target",
|
|
|
|
"version": 1,
|
2020-06-02 19:33:13 +00:00
|
|
|
"workspace_root": "[..]/foo",
|
|
|
|
"metadata": null
|
2018-12-30 04:46:15 +00:00
|
|
|
}"#,
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
// --no-deps uses a different code path, make sure both work.
|
|
|
|
p.cargo("metadata --format-version=1")
|
|
|
|
.with_json(
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"packages": [
|
2020-07-15 23:22:28 +00:00
|
|
|
{
|
|
|
|
"name": "altdep",
|
|
|
|
"version": "0.0.1",
|
2023-11-02 16:37:14 +00:00
|
|
|
"id": "registry+file:[..]/alternative-registry#altdep@0.0.1",
|
2020-07-15 23:22:28 +00:00
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
|
|
|
"source": "registry+file:[..]/alternative-registry",
|
|
|
|
"dependencies": [
|
|
|
|
{
|
|
|
|
"name": "bar",
|
|
|
|
"source": "registry+https://github.com/rust-lang/crates.io-index",
|
|
|
|
"req": "^0.0.1",
|
|
|
|
"kind": null,
|
|
|
|
"rename": null,
|
|
|
|
"optional": false,
|
|
|
|
"uses_default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"target": null,
|
|
|
|
"registry": null
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"targets": "{...}",
|
|
|
|
"features": {},
|
|
|
|
"manifest_path": "[..]/altdep-0.0.1/Cargo.toml",
|
|
|
|
"metadata": null,
|
|
|
|
"publish": null,
|
|
|
|
"authors": [],
|
|
|
|
"categories": [],
|
2021-06-07 06:17:34 +00:00
|
|
|
"default_run": null,
|
2020-07-15 23:22:28 +00:00
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
2021-10-08 17:00:39 +00:00
|
|
|
"rust_version": null,
|
2020-10-01 09:22:49 +00:00
|
|
|
"homepage": null,
|
|
|
|
"documentation": null,
|
2020-07-15 23:22:28 +00:00
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
},
|
2018-12-30 04:46:15 +00:00
|
|
|
{
|
|
|
|
"name": "altdep2",
|
|
|
|
"version": "0.0.1",
|
2023-11-02 16:37:14 +00:00
|
|
|
"id": "registry+file:[..]/alternative-registry#altdep2@0.0.1",
|
2018-12-30 04:46:15 +00:00
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
|
|
|
"source": "registry+file:[..]/alternative-registry",
|
|
|
|
"dependencies": [],
|
|
|
|
"targets": "{...}",
|
|
|
|
"features": {},
|
|
|
|
"manifest_path": "[..]/altdep2-0.0.1/Cargo.toml",
|
|
|
|
"metadata": null,
|
2019-09-11 18:46:12 +00:00
|
|
|
"publish": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"authors": [],
|
|
|
|
"categories": [],
|
2021-06-07 06:17:34 +00:00
|
|
|
"default_run": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
2021-10-08 17:00:39 +00:00
|
|
|
"rust_version": null,
|
2020-10-01 09:22:49 +00:00
|
|
|
"homepage": null,
|
|
|
|
"documentation": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
},
|
|
|
|
{
|
2020-07-15 23:22:28 +00:00
|
|
|
"name": "bar",
|
2018-12-30 04:46:15 +00:00
|
|
|
"version": "0.0.1",
|
2023-11-02 16:37:14 +00:00
|
|
|
"id": "registry+https://github.com/rust-lang/crates.io-index#bar@0.0.1",
|
2018-12-30 04:46:15 +00:00
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
2020-07-15 23:22:28 +00:00
|
|
|
"source": "registry+https://github.com/rust-lang/crates.io-index",
|
|
|
|
"dependencies": [],
|
2018-12-30 04:46:15 +00:00
|
|
|
"targets": "{...}",
|
|
|
|
"features": {},
|
2020-07-15 23:22:28 +00:00
|
|
|
"manifest_path": "[..]/bar-0.0.1/Cargo.toml",
|
2018-12-30 04:46:15 +00:00
|
|
|
"metadata": null,
|
2019-09-11 18:46:12 +00:00
|
|
|
"publish": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"authors": [],
|
|
|
|
"categories": [],
|
2021-06-07 06:17:34 +00:00
|
|
|
"default_run": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
2021-10-08 17:00:39 +00:00
|
|
|
"rust_version": null,
|
2020-10-01 09:22:49 +00:00
|
|
|
"homepage": null,
|
|
|
|
"documentation": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "foo",
|
|
|
|
"version": "0.0.1",
|
2023-11-02 16:37:14 +00:00
|
|
|
"id": "path+file:[..]/foo#0.0.1",
|
2018-12-30 04:46:15 +00:00
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
|
|
|
"source": null,
|
|
|
|
"dependencies": [
|
|
|
|
{
|
|
|
|
"name": "altdep",
|
|
|
|
"source": "registry+file:[..]/alternative-registry",
|
|
|
|
"req": "^0.0.1",
|
|
|
|
"kind": null,
|
|
|
|
"rename": null,
|
|
|
|
"optional": false,
|
|
|
|
"uses_default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"target": null,
|
|
|
|
"registry": "file:[..]/alternative-registry"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "iodep",
|
|
|
|
"source": "registry+https://github.com/rust-lang/crates.io-index",
|
|
|
|
"req": "^0.0.1",
|
|
|
|
"kind": null,
|
|
|
|
"rename": null,
|
|
|
|
"optional": false,
|
|
|
|
"uses_default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"target": null,
|
|
|
|
"registry": null
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"targets": "{...}",
|
|
|
|
"features": {},
|
|
|
|
"manifest_path": "[..]/foo/Cargo.toml",
|
|
|
|
"metadata": null,
|
2019-09-11 18:46:12 +00:00
|
|
|
"publish": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"authors": [],
|
|
|
|
"categories": [],
|
2021-06-07 06:17:34 +00:00
|
|
|
"default_run": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
2021-10-08 17:00:39 +00:00
|
|
|
"rust_version": null,
|
2020-10-01 09:22:49 +00:00
|
|
|
"homepage": null,
|
|
|
|
"documentation": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "iodep",
|
|
|
|
"version": "0.0.1",
|
2023-11-02 16:37:14 +00:00
|
|
|
"id": "registry+https://github.com/rust-lang/crates.io-index#iodep@0.0.1",
|
2018-12-30 04:46:15 +00:00
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
|
|
|
"source": "registry+https://github.com/rust-lang/crates.io-index",
|
|
|
|
"dependencies": [
|
|
|
|
{
|
|
|
|
"name": "altdep2",
|
|
|
|
"source": "registry+file:[..]/alternative-registry",
|
|
|
|
"req": "^0.0.1",
|
|
|
|
"kind": null,
|
|
|
|
"rename": null,
|
|
|
|
"optional": false,
|
|
|
|
"uses_default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"target": null,
|
|
|
|
"registry": "file:[..]/alternative-registry"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"targets": "{...}",
|
|
|
|
"features": {},
|
|
|
|
"manifest_path": "[..]/iodep-0.0.1/Cargo.toml",
|
|
|
|
"metadata": null,
|
2019-09-11 18:46:12 +00:00
|
|
|
"publish": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"authors": [],
|
|
|
|
"categories": [],
|
2021-06-07 06:17:34 +00:00
|
|
|
"default_run": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
2021-10-08 17:00:39 +00:00
|
|
|
"rust_version": null,
|
2020-10-01 09:22:49 +00:00
|
|
|
"homepage": null,
|
|
|
|
"documentation": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"workspace_members": [
|
2023-11-02 16:37:14 +00:00
|
|
|
"path+file:[..]/foo#0.0.1"
|
2018-12-30 04:46:15 +00:00
|
|
|
],
|
2023-05-03 08:37:37 +00:00
|
|
|
"workspace_default_members": [
|
2023-11-02 16:37:14 +00:00
|
|
|
"path+file:[..]/foo#0.0.1"
|
2023-05-03 08:37:37 +00:00
|
|
|
],
|
2018-12-30 04:46:15 +00:00
|
|
|
"resolve": "{...}",
|
|
|
|
"target_directory": "[..]/foo/target",
|
|
|
|
"version": 1,
|
2020-06-02 19:33:13 +00:00
|
|
|
"workspace_root": "[..]/foo",
|
|
|
|
"metadata": null
|
2018-12-30 04:46:15 +00:00
|
|
|
}"#,
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2018-12-31 00:07:58 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-12-31 00:07:58 +00:00
|
|
|
fn unknown_registry() {
|
|
|
|
// A known registry refers to an unknown registry.
|
|
|
|
// foo -> bar(crates.io) -> baz(alt)
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
2018-12-31 00:07:58 +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 = []
|
2018-12-31 00:07:58 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
"#,
|
2018-12-31 00:07:58 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2019-01-27 13:39:49 +00:00
|
|
|
Package::new("baz", "0.0.1").alternative(true).publish();
|
2018-12-31 00:07:58 +00:00
|
|
|
Package::new("bar", "0.0.1")
|
|
|
|
.registry_dep("baz", "0.0.1")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
// Remove "alternative" from config.
|
2024-01-26 19:40:46 +00:00
|
|
|
let cfg_path = paths::home().join(".cargo/config.toml");
|
2018-12-31 00:07:58 +00:00
|
|
|
let mut config = fs::read_to_string(&cfg_path).unwrap();
|
|
|
|
let start = config.find("[registries.alternative]").unwrap();
|
|
|
|
config.insert(start, '#');
|
|
|
|
let start_index = &config[start..].find("index =").unwrap();
|
|
|
|
config.insert(start + start_index, '#');
|
|
|
|
fs::write(&cfg_path, config).unwrap();
|
|
|
|
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check").run();
|
2018-12-31 00:07:58 +00:00
|
|
|
|
|
|
|
// Important parts:
|
|
|
|
// foo -> bar registry = null
|
|
|
|
// bar -> baz registry = alternate
|
|
|
|
p.cargo("metadata --format-version=1")
|
2019-01-27 13:39:49 +00:00
|
|
|
.with_json(
|
|
|
|
r#"
|
2018-12-31 00:07:58 +00:00
|
|
|
{
|
|
|
|
"packages": [
|
|
|
|
{
|
2020-07-15 23:22:28 +00:00
|
|
|
"name": "bar",
|
2018-12-31 00:07:58 +00:00
|
|
|
"version": "0.0.1",
|
2023-11-02 16:37:14 +00:00
|
|
|
"id": "registry+https://github.com/rust-lang/crates.io-index#bar@0.0.1",
|
2018-12-31 00:07:58 +00:00
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
2020-07-15 23:22:28 +00:00
|
|
|
"source": "registry+https://github.com/rust-lang/crates.io-index",
|
|
|
|
"dependencies": [
|
|
|
|
{
|
|
|
|
"name": "baz",
|
|
|
|
"source": "registry+file://[..]/alternative-registry",
|
|
|
|
"req": "^0.0.1",
|
|
|
|
"kind": null,
|
|
|
|
"rename": null,
|
|
|
|
"optional": false,
|
|
|
|
"uses_default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"target": null,
|
|
|
|
"registry": "file:[..]/alternative-registry"
|
|
|
|
}
|
|
|
|
],
|
2018-12-31 00:07:58 +00:00
|
|
|
"targets": "{...}",
|
|
|
|
"features": {},
|
|
|
|
"manifest_path": "[..]",
|
|
|
|
"metadata": null,
|
2019-09-11 18:46:12 +00:00
|
|
|
"publish": null,
|
2018-12-31 00:07:58 +00:00
|
|
|
"authors": [],
|
|
|
|
"categories": [],
|
2021-06-07 06:17:34 +00:00
|
|
|
"default_run": null,
|
2018-12-31 00:07:58 +00:00
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
2021-10-08 17:00:39 +00:00
|
|
|
"rust_version": null,
|
2020-10-01 09:22:49 +00:00
|
|
|
"homepage": null,
|
|
|
|
"documentation": null,
|
2018-12-31 00:07:58 +00:00
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
},
|
|
|
|
{
|
2020-07-15 23:22:28 +00:00
|
|
|
"name": "baz",
|
2018-12-31 00:07:58 +00:00
|
|
|
"version": "0.0.1",
|
2023-11-02 16:37:14 +00:00
|
|
|
"id": "registry+file://[..]/alternative-registry#baz@0.0.1",
|
2018-12-31 00:07:58 +00:00
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
2020-07-15 23:22:28 +00:00
|
|
|
"source": "registry+file://[..]/alternative-registry",
|
|
|
|
"dependencies": [],
|
2018-12-31 00:07:58 +00:00
|
|
|
"targets": "{...}",
|
|
|
|
"features": {},
|
2020-07-15 23:22:28 +00:00
|
|
|
"manifest_path": "[..]",
|
2018-12-31 00:07:58 +00:00
|
|
|
"metadata": null,
|
2019-09-11 18:46:12 +00:00
|
|
|
"publish": null,
|
2018-12-31 00:07:58 +00:00
|
|
|
"authors": [],
|
|
|
|
"categories": [],
|
2021-06-07 06:17:34 +00:00
|
|
|
"default_run": null,
|
2018-12-31 00:07:58 +00:00
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
2021-10-08 17:00:39 +00:00
|
|
|
"rust_version": null,
|
2020-10-01 09:22:49 +00:00
|
|
|
"homepage": null,
|
|
|
|
"documentation": null,
|
2018-12-31 00:07:58 +00:00
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
},
|
|
|
|
{
|
2020-07-15 23:22:28 +00:00
|
|
|
"name": "foo",
|
2018-12-31 00:07:58 +00:00
|
|
|
"version": "0.0.1",
|
2023-11-02 16:37:14 +00:00
|
|
|
"id": "path+file://[..]/foo#0.0.1",
|
2018-12-31 00:07:58 +00:00
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
2020-07-15 23:22:28 +00:00
|
|
|
"source": null,
|
2018-12-31 00:07:58 +00:00
|
|
|
"dependencies": [
|
|
|
|
{
|
2020-07-15 23:22:28 +00:00
|
|
|
"name": "bar",
|
|
|
|
"source": "registry+https://github.com/rust-lang/crates.io-index",
|
2018-12-31 00:07:58 +00:00
|
|
|
"req": "^0.0.1",
|
|
|
|
"kind": null,
|
|
|
|
"rename": null,
|
|
|
|
"optional": false,
|
|
|
|
"uses_default_features": true,
|
|
|
|
"features": [],
|
|
|
|
"target": null,
|
2020-07-15 23:22:28 +00:00
|
|
|
"registry": null
|
2018-12-31 00:07:58 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"targets": "{...}",
|
|
|
|
"features": {},
|
2020-07-15 23:22:28 +00:00
|
|
|
"manifest_path": "[..]/foo/Cargo.toml",
|
2018-12-31 00:07:58 +00:00
|
|
|
"metadata": null,
|
2019-09-11 18:46:12 +00:00
|
|
|
"publish": null,
|
2018-12-31 00:07:58 +00:00
|
|
|
"authors": [],
|
|
|
|
"categories": [],
|
2021-06-07 06:17:34 +00:00
|
|
|
"default_run": null,
|
2018-12-31 00:07:58 +00:00
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
2021-10-08 17:00:39 +00:00
|
|
|
"rust_version": null,
|
2020-10-01 09:22:49 +00:00
|
|
|
"homepage": null,
|
|
|
|
"documentation": null,
|
2018-12-31 00:07:58 +00:00
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"workspace_members": [
|
2023-11-02 16:37:14 +00:00
|
|
|
"path+file://[..]/foo#0.0.1"
|
2018-12-31 00:07:58 +00:00
|
|
|
],
|
2023-05-03 08:37:37 +00:00
|
|
|
"workspace_default_members": [
|
2023-11-02 16:37:14 +00:00
|
|
|
"path+file://[..]/foo#0.0.1"
|
2023-05-03 08:37:37 +00:00
|
|
|
],
|
2018-12-31 00:07:58 +00:00
|
|
|
"resolve": "{...}",
|
|
|
|
"target_directory": "[..]/foo/target",
|
|
|
|
"version": 1,
|
2020-06-02 19:33:13 +00:00
|
|
|
"workspace_root": "[..]/foo",
|
|
|
|
"metadata": null
|
2018-12-31 00:07:58 +00:00
|
|
|
}
|
2019-01-27 13:39:49 +00:00
|
|
|
"#,
|
|
|
|
)
|
2018-12-31 00:07:58 +00:00
|
|
|
.run();
|
|
|
|
}
|
2019-04-27 23:01:43 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-04-29 17:39:21 +00:00
|
|
|
fn registries_index_relative_url() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
2024-01-26 19:40:46 +00:00
|
|
|
let config = paths::root().join(".cargo/config.toml");
|
2019-04-27 23:01:43 +00:00
|
|
|
fs::create_dir_all(config.parent().unwrap()).unwrap();
|
2020-04-17 04:10:11 +00:00
|
|
|
fs::write(
|
|
|
|
&config,
|
|
|
|
r#"
|
2019-04-27 23:01:43 +00:00
|
|
|
[registries.relative]
|
2019-04-29 17:39:21 +00:00
|
|
|
index = "file:alternative-registry"
|
2019-05-01 21:39:15 +00:00
|
|
|
"#,
|
2020-04-17 04:10:11 +00:00
|
|
|
)
|
|
|
|
.unwrap();
|
2019-04-27 23:01:43 +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 = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "relative"
|
|
|
|
"#,
|
2019-04-27 23:01:43 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2019-05-01 21:39:15 +00:00
|
|
|
Package::new("bar", "0.0.1").alternative(true).publish();
|
2019-04-27 23:01:43 +00:00
|
|
|
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check")
|
2021-06-27 19:18:36 +00:00
|
|
|
.with_stderr(
|
2019-04-27 23:01:43 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `relative` index
|
2019-04-27 23:01:43 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2021-06-27 19:18:36 +00:00
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `relative`)
|
2023-02-03 20:59:17 +00:00
|
|
|
[CHECKING] bar v0.0.1 (registry `relative`)
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2019-04-27 23:01:43 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
|
|
|
",
|
2021-06-27 19:18:36 +00:00
|
|
|
)
|
2019-04-27 23:01:43 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-04-29 17:39:21 +00:00
|
|
|
fn registries_index_relative_path_not_allowed() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
2024-01-26 19:40:46 +00:00
|
|
|
let config = paths::root().join(".cargo/config.toml");
|
2019-04-29 17:39:21 +00:00
|
|
|
fs::create_dir_all(config.parent().unwrap()).unwrap();
|
2020-04-17 04:10:11 +00:00
|
|
|
fs::write(
|
|
|
|
&config,
|
|
|
|
r#"
|
2019-04-29 17:39:21 +00:00
|
|
|
[registries.relative]
|
|
|
|
index = "alternative-registry"
|
2019-05-01 21:39:15 +00:00
|
|
|
"#,
|
2020-04-17 04:10:11 +00:00
|
|
|
)
|
|
|
|
.unwrap();
|
2019-04-29 17:39:21 +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 = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "relative"
|
|
|
|
"#,
|
2019-04-29 17:39:21 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
2019-05-01 21:39:15 +00:00
|
|
|
Package::new("bar", "0.0.1").alternative(true).publish();
|
2019-04-29 17:39:21 +00:00
|
|
|
|
2023-02-03 20:59:17 +00:00
|
|
|
p.cargo("check")
|
2019-04-29 17:39:21 +00:00
|
|
|
.with_stderr(&format!(
|
|
|
|
"\
|
|
|
|
error: failed to parse manifest at `{root}/foo/Cargo.toml`
|
|
|
|
|
2020-05-25 18:17:28 +00:00
|
|
|
Caused by:
|
2024-01-26 19:40:46 +00:00
|
|
|
invalid index URL for registry `relative` defined in [..]/.cargo/config.toml
|
2020-05-25 18:17:28 +00:00
|
|
|
|
2019-04-29 17:39:21 +00:00
|
|
|
Caused by:
|
|
|
|
invalid url `alternative-registry`: relative URL without a base
|
2019-05-01 21:39:15 +00:00
|
|
|
",
|
|
|
|
root = paths::root().to_str().unwrap()
|
|
|
|
))
|
2019-04-29 17:39:21 +00:00
|
|
|
.with_status(101)
|
|
|
|
.run();
|
|
|
|
}
|
2020-03-06 18:15:14 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn both_index_and_registry() {
|
|
|
|
let p = project().file("src/lib.rs", "").build();
|
2022-04-18 17:03:01 +00:00
|
|
|
for cmd in &["publish", "owner", "search", "yank --version 1.0.0"] {
|
2020-03-06 18:15:14 +00:00
|
|
|
p.cargo(cmd)
|
|
|
|
.arg("--registry=foo")
|
|
|
|
.arg("--index=foo")
|
2023-09-15 14:11:10 +00:00
|
|
|
.with_status(1)
|
|
|
|
.with_stderr_contains(
|
|
|
|
"error: the argument '--registry <REGISTRY>' cannot be used with '--index <INDEX>'",
|
2020-03-06 18:15:14 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
}
|
2022-09-10 03:30:34 +00:00
|
|
|
|
2022-10-27 15:59:07 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn both_index_and_default() {
|
|
|
|
let p = project().file("src/lib.rs", "").build();
|
|
|
|
for cmd in &[
|
|
|
|
"publish",
|
|
|
|
"owner",
|
|
|
|
"search",
|
|
|
|
"yank --version 1.0.0",
|
|
|
|
"install foo",
|
|
|
|
] {
|
|
|
|
p.cargo(cmd)
|
|
|
|
.env("CARGO_REGISTRY_DEFAULT", "undefined")
|
|
|
|
.arg(format!("--index=index_url"))
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr("[ERROR] invalid url `index_url`: relative URL without a base")
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-10 03:30:34 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn sparse_lockfile() {
|
|
|
|
let _registry = registry::RegistryBuilder::new()
|
|
|
|
.http_index()
|
|
|
|
.alternative()
|
|
|
|
.build();
|
|
|
|
Package::new("foo", "0.1.0").alternative(true).publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[project]
|
|
|
|
name = "a"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = { registry = 'alternative', version = '0.1.0'}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-10-13 21:00:23 +00:00
|
|
|
p.cargo("generate-lockfile").run();
|
2022-09-10 03:30:34 +00:00
|
|
|
assert_match_exact(
|
|
|
|
&p.read_lockfile(),
|
|
|
|
r#"# This file is automatically @generated by Cargo.
|
|
|
|
# It is not intended for manual editing.
|
|
|
|
version = 3
|
|
|
|
|
|
|
|
[[package]]
|
|
|
|
name = "a"
|
|
|
|
version = "0.5.0"
|
|
|
|
dependencies = [
|
|
|
|
"foo",
|
|
|
|
]
|
|
|
|
|
|
|
|
[[package]]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
source = "sparse+http://[..]/"
|
|
|
|
checksum = "f6a200a9339fef960979d94d5c99cbbfd899b6f5a396a55d9775089119050203""#,
|
|
|
|
);
|
|
|
|
}
|
2022-10-20 22:21:32 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn publish_with_transitive_dep() {
|
|
|
|
let _alt1 = RegistryBuilder::new()
|
|
|
|
.http_api()
|
|
|
|
.http_index()
|
|
|
|
.alternative_named("Alt-1")
|
|
|
|
.build();
|
|
|
|
let _alt2 = RegistryBuilder::new()
|
|
|
|
.http_api()
|
|
|
|
.http_index()
|
|
|
|
.alternative_named("Alt-2")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p1 = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "a"
|
|
|
|
version = "0.5.0"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
2022-10-13 21:00:23 +00:00
|
|
|
p1.cargo("publish --registry Alt-1").run();
|
2022-10-20 22:21:32 +00:00
|
|
|
|
|
|
|
let p2 = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "b"
|
|
|
|
version = "0.6.0"
|
|
|
|
publish = ["Alt-2"]
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
a = { version = "0.5.0", registry = "Alt-1" }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
2022-10-13 21:00:23 +00:00
|
|
|
p2.cargo("publish").run();
|
2022-10-20 22:21:32 +00:00
|
|
|
}
|
2023-08-02 23:03:04 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn warn_for_unused_fields() {
|
|
|
|
let _ = RegistryBuilder::new()
|
|
|
|
.no_configure_token()
|
|
|
|
.alternative()
|
|
|
|
.build();
|
|
|
|
let p = project()
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(
|
|
|
|
".cargo/config.toml",
|
|
|
|
"[registry]
|
|
|
|
unexpected-field = 'foo'
|
|
|
|
[registries.alternative]
|
|
|
|
unexpected-field = 'foo'
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish --registry alternative")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `alternative` index
|
|
|
|
[WARNING] unused config key `registries.alternative.unexpected-field` in `[..]config.toml`
|
|
|
|
[ERROR] no token found for `alternative`, please run `cargo login --registry alternative`
|
|
|
|
or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
p.cargo("publish --registry crates-io")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] crates.io index
|
|
|
|
[WARNING] unused config key `registry.unexpected-field` in `[..]config.toml`
|
|
|
|
[ERROR] no token found, please run `cargo login`
|
|
|
|
or use environment variable CARGO_REGISTRY_TOKEN",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2023-12-13 16:15:57 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn config_empty_registry_name() {
|
|
|
|
let _ = RegistryBuilder::new()
|
|
|
|
.no_configure_token()
|
|
|
|
.alternative()
|
|
|
|
.build();
|
|
|
|
let p = project()
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(
|
|
|
|
".cargo/config.toml",
|
|
|
|
"[registry.'']
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("publish")
|
|
|
|
.arg("--registry")
|
|
|
|
.arg("")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2023-12-13 15:40:32 +00:00
|
|
|
[ERROR] registry name cannot be empty",
|
2023-12-13 16:15:57 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn empty_registry_flag() {
|
|
|
|
let p = project().file("src/lib.rs", "").build();
|
|
|
|
|
|
|
|
p.cargo("publish")
|
|
|
|
.arg("--registry")
|
|
|
|
.arg("")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2023-12-13 15:40:32 +00:00
|
|
|
[ERROR] registry name cannot be empty",
|
2023-12-13 16:15:57 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn empty_dependency_registry() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { version = "0.1.0", registry = "" }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"
|
|
|
|
extern crate bar;
|
|
|
|
pub fn f() { bar::bar(); }
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2023-12-14 22:28:05 +00:00
|
|
|
[ERROR] registry name cannot be empty
|
2023-12-13 17:37:08 +00:00
|
|
|
|
|
|
|
|
2023-12-14 22:28:05 +00:00
|
|
|
--> Cargo.toml:7:23
|
|
|
|
|
|
|
|
|
7 | bar = { version = \"0.1.0\", registry = \"\" }
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2023-12-13 17:37:08 +00:00
|
|
|
",
|
2023-12-13 16:15:57 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|