2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for alternative registries.
|
|
|
|
|
2019-09-12 19:52:46 +00:00
|
|
|
use cargo::util::IntoUrl;
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::publish::validate_alt_upload;
|
|
|
|
use cargo_test_support::registry::{self, Package};
|
|
|
|
use cargo_test_support::{basic_manifest, git, 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() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-08-30 05:55:31 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr(&format!(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `{reg}` index
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `[ROOT][..]`)
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[COMPILING] 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-09-08 02:42:26 +00:00
|
|
|
reg = registry::alt_registry_path().to_str().unwrap()
|
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
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
2018-08-29 17:56:48 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[COMPILING] 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() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-10-06 22:34:00 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr(&format!(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `{reg}` index
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `[ROOT][..]`)
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] baz v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[COMPILING] 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
|
|
|
",
|
2018-09-08 02:42:26 +00:00
|
|
|
reg = registry::alt_registry_path().to_str().unwrap()
|
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() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-11-08 05:42:48 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr(&format!(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `{reg}` index
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[DOWNLOADED] [..] v0.0.1 (registry `[ROOT][..]`)
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] baz v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[COMPILING] 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
|
|
|
",
|
2018-09-08 02:42:26 +00:00
|
|
|
reg = registry::alt_registry_path().to_str().unwrap()
|
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() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-10-06 22:34:00 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
2018-12-20 01:40:01 +00:00
|
|
|
.with_stderr_unordered(&format!(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `{alt_reg}` index
|
|
|
|
[UPDATING] `{reg}` index
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
2018-12-20 01:40:01 +00:00
|
|
|
[DOWNLOADED] baz v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `[ROOT][..]`)
|
2018-12-30 04:46:15 +00:00
|
|
|
[COMPILING] baz v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[COMPILING] 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
|
|
|
",
|
2018-09-08 02:42:26 +00:00
|
|
|
alt_reg = registry::alt_registry_path().to_str().unwrap(),
|
|
|
|
reg = registry::registry_path().to_str().unwrap()
|
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() {
|
|
|
|
registry::init();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-08-30 05:55:31 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
2018-01-20 06:31:11 +00:00
|
|
|
path = "bar"
|
2017-08-30 05:55:31 +00:00
|
|
|
registry = "alternative"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
2018-08-29 17:56:48 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] bar v0.0.1 ([CWD]/bar)
|
|
|
|
[COMPILING] 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() {
|
2018-01-20 06:31:11 +00:00
|
|
|
registry::init();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-08-30 05:55:31 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
git = ""
|
|
|
|
registry = "alternative"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.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() {
|
2019-01-05 18:56:49 +00:00
|
|
|
let fakeio_path = paths::root().join("fake.io");
|
2019-06-20 14:30:24 +00:00
|
|
|
let fakeio_url = fakeio_path.into_url().unwrap();
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-11-06 20:37:40 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2019-01-05 18:56:49 +00:00
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[registries.fakeio]
|
|
|
|
index = "{}"
|
|
|
|
"#,
|
|
|
|
fakeio_url
|
|
|
|
),
|
|
|
|
)
|
2017-11-06 20:37:40 +00:00
|
|
|
.build();
|
|
|
|
|
|
|
|
Package::new("bar", "0.0.1").alternative(true).publish();
|
|
|
|
|
2019-01-05 18:56:49 +00:00
|
|
|
// Since this can't really call plain `publish` without fetching the real
|
|
|
|
// crates.io index, create a fake one that points to the real crates.io.
|
|
|
|
git::repo(&fakeio_path)
|
|
|
|
.file(
|
|
|
|
"config.json",
|
|
|
|
r#"
|
|
|
|
{"dl": "https://crates.io/api/v1/crates", "api": "https://crates.io"}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
2019-04-15 18:00:42 +00:00
|
|
|
// Login so that we have the token available
|
|
|
|
p.cargo("login --registry fakeio TOKEN").run();
|
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("publish --registry fakeio")
|
2019-01-05 18:56:49 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains("[ERROR] crates cannot be published to crates.io[..]")
|
|
|
|
.run();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish --index")
|
2019-01-05 18:56:49 +00:00
|
|
|
.arg(fakeio_url.to_string())
|
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() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-08-30 05:55:31 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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();
|
|
|
|
|
2017-11-01 22:14:33 +00:00
|
|
|
// Login so that we have the token available
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("login --registry alternative TOKEN").run();
|
2018-08-28 09:20:03 +00:00
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("publish --registry alternative").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,
|
|
|
|
"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() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-10-21 19:10:25 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
crates_io_dep = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies.alt_reg_dep]
|
|
|
|
version = "0.1.0"
|
|
|
|
registry = "alternative"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr_contains(format!(
|
2018-09-08 09:23:57 +00:00
|
|
|
"[UPDATING] `{}` index",
|
2018-09-08 02:42:26 +00:00
|
|
|
registry::alt_registry_path().to_str().unwrap()
|
2018-12-08 11:19:47 +00:00
|
|
|
))
|
|
|
|
.with_stderr_contains(&format!(
|
2018-09-09 23:48:57 +00:00
|
|
|
"[UPDATING] `{}` index",
|
2018-12-08 11:19:47 +00:00
|
|
|
registry::registry_path().to_str().unwrap()
|
|
|
|
))
|
2018-09-14 20:33:18 +00:00
|
|
|
.with_stderr_contains("[DOWNLOADED] crates_io_dep v0.0.1 (registry `[ROOT][..]`)")
|
|
|
|
.with_stderr_contains("[DOWNLOADED] alt_reg_dep v0.1.0 (registry `[ROOT][..]`)")
|
2018-09-08 02:42:26 +00:00
|
|
|
.with_stderr_contains("[COMPILING] alt_reg_dep v0.1.0 (registry `[ROOT][..]`)")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr_contains("[COMPILING] crates_io_dep v0.0.1")
|
2018-09-08 02:42:26 +00:00
|
|
|
.with_stderr_contains("[COMPILING] foo v0.0.1 ([CWD])")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr_contains("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s")
|
|
|
|
.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() {
|
2018-08-28 09:20:03 +00:00
|
|
|
let p = project().file("src/main.rs", "fn main() {}").build();
|
2017-10-30 14:29:37 +00:00
|
|
|
|
|
|
|
// Setup the registry by publishing a package
|
|
|
|
Package::new("bar", "0.0.1").alternative(true).publish();
|
|
|
|
|
2019-01-11 23:56:46 +00:00
|
|
|
fs::remove_file(paths::home().join(".cargo/credentials")).unwrap();
|
|
|
|
|
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)
|
|
|
|
.with_stderr_contains("error: no upload token found, please run `cargo login`")
|
|
|
|
.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() {
|
2019-02-11 23:16:13 +00:00
|
|
|
let p = project().file("src/main.rs", "fn main() {}").build();
|
2017-10-30 14:29:37 +00:00
|
|
|
|
|
|
|
// Setup the registry by publishing a package
|
|
|
|
Package::new("bar", "0.0.1").alternative(true).publish();
|
|
|
|
|
|
|
|
// Login so that we have the token available
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("login --registry alternative TOKEN").run();
|
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").run();
|
2017-10-31 22:11:02 +00:00
|
|
|
|
2018-12-30 04:46:15 +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,
|
|
|
|
"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-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() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-11-01 22:14:33 +00:00
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = ["me"]
|
|
|
|
license = "MIT"
|
|
|
|
description = "foo"
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
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();
|
|
|
|
|
|
|
|
// Login so that we have the token available
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("login --registry alternative TOKEN").run();
|
2018-08-28 09:20:03 +00:00
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("publish --registry alternative").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,
|
|
|
|
"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() {
|
2018-01-24 20:54:17 +00:00
|
|
|
registry::init();
|
|
|
|
|
|
|
|
let config = paths::home().join(".cargo/config");
|
|
|
|
|
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)
|
2018-10-31 01:01:44 +00:00
|
|
|
.with_stderr_contains("error: 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() {
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { version = "0.1.0", registry = "alternative" }
|
|
|
|
|
|
|
|
[patch.alternative]
|
|
|
|
bar = { path = "bar" }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.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();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `[ROOT][..]` index
|
|
|
|
[COMPILING] bar v0.1.0 ([CWD]/bar)
|
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
|
|
|
[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#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "bad name"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] failed to parse manifest at `[CWD]/Cargo.toml`
|
|
|
|
|
|
|
|
Caused by:
|
2020-03-02 22:26:21 +00:00
|
|
|
invalid character ` ` in registry name: `bad name`, [..]",
|
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",
|
|
|
|
"yank",
|
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() {
|
|
|
|
Package::new("bar", "0.0.1").alternative(true).publish();
|
|
|
|
// Configure without `api`.
|
|
|
|
let repo = git2::Repository::open(registry::alt_registry_path()).unwrap();
|
|
|
|
let cfg_path = registry::alt_registry_path().join("config.json");
|
|
|
|
fs::write(
|
|
|
|
cfg_path,
|
|
|
|
format!(r#"{{"dl": "{}"}}"#, registry::alt_dl_url()),
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
git::add(&repo);
|
|
|
|
git::commit(&repo);
|
|
|
|
|
|
|
|
// First check that a dependency works.
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "alternative"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr(&format!(
|
|
|
|
"\
|
|
|
|
[UPDATING] `{reg}` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
|
|
|
",
|
|
|
|
reg = registry::alt_registry_path().to_str().unwrap()
|
|
|
|
))
|
|
|
|
.run();
|
|
|
|
|
|
|
|
// Check all of the API commands.
|
|
|
|
let err = format!(
|
|
|
|
"[ERROR] registry `{}` does not support API commands",
|
|
|
|
registry::alt_registry_path().display()
|
|
|
|
);
|
|
|
|
|
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();
|
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("yank --registry alternative --vers=0.0.1 bar")
|
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("yank --registry alternative --vers=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.
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
altdep = { version = "0.0.1", registry = "alternative" }
|
|
|
|
iodep = { version = "0.0.1" }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.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",
|
|
|
|
"id": "foo 0.0.1 (path+file:[..]/foo)",
|
|
|
|
"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": [],
|
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"workspace_members": [
|
|
|
|
"foo 0.0.1 (path+file:[..]/foo)"
|
|
|
|
],
|
|
|
|
"resolve": null,
|
|
|
|
"target_directory": "[..]/foo/target",
|
|
|
|
"version": 1,
|
|
|
|
"workspace_root": "[..]/foo"
|
|
|
|
}"#,
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
// --no-deps uses a different code path, make sure both work.
|
|
|
|
p.cargo("metadata --format-version=1")
|
|
|
|
.with_json(
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"packages": [
|
|
|
|
{
|
|
|
|
"name": "altdep2",
|
|
|
|
"version": "0.0.1",
|
|
|
|
"id": "altdep2 0.0.1 (registry+file:[..]/alternative-registry)",
|
|
|
|
"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": [],
|
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "altdep",
|
|
|
|
"version": "0.0.1",
|
|
|
|
"id": "altdep 0.0.1 (registry+file:[..]/alternative-registry)",
|
|
|
|
"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,
|
2019-09-11 18:46:12 +00:00
|
|
|
"publish": null,
|
2018-12-30 04:46:15 +00:00
|
|
|
"authors": [],
|
|
|
|
"categories": [],
|
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "foo",
|
|
|
|
"version": "0.0.1",
|
|
|
|
"id": "foo 0.0.1 (path+file:[..]/foo)",
|
|
|
|
"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": [],
|
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "iodep",
|
|
|
|
"version": "0.0.1",
|
|
|
|
"id": "iodep 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
|
|
"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": [],
|
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "bar",
|
|
|
|
"version": "0.0.1",
|
|
|
|
"id": "bar 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
|
|
|
"source": "registry+https://github.com/rust-lang/crates.io-index",
|
|
|
|
"dependencies": [],
|
|
|
|
"targets": "{...}",
|
|
|
|
"features": {},
|
|
|
|
"manifest_path": "[..]/bar-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": [],
|
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"workspace_members": [
|
|
|
|
"foo 0.0.1 (path+file:[..]/foo)"
|
|
|
|
],
|
|
|
|
"resolve": "{...}",
|
|
|
|
"target_directory": "[..]/foo/target",
|
|
|
|
"version": 1,
|
|
|
|
"workspace_root": "[..]/foo"
|
|
|
|
}"#,
|
|
|
|
)
|
|
|
|
.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)
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.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.
|
|
|
|
let cfg_path = paths::home().join(".cargo/config");
|
|
|
|
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();
|
|
|
|
|
2019-02-11 23:16:13 +00:00
|
|
|
p.cargo("build").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": [
|
|
|
|
{
|
|
|
|
"name": "baz",
|
|
|
|
"version": "0.0.1",
|
|
|
|
"id": "baz 0.0.1 (registry+file://[..]/alternative-registry)",
|
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
|
|
|
"source": "registry+file://[..]/alternative-registry",
|
|
|
|
"dependencies": [],
|
|
|
|
"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": [],
|
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "foo",
|
|
|
|
"version": "0.0.1",
|
|
|
|
"id": "foo 0.0.1 (path+file://[..]/foo)",
|
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
|
|
|
"source": null,
|
|
|
|
"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": "[..]/foo/Cargo.toml",
|
|
|
|
"metadata": null,
|
2019-09-11 18:46:12 +00:00
|
|
|
"publish": null,
|
2018-12-31 00:07:58 +00:00
|
|
|
"authors": [],
|
|
|
|
"categories": [],
|
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "bar",
|
|
|
|
"version": "0.0.1",
|
|
|
|
"id": "bar 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
|
|
"license": null,
|
|
|
|
"license_file": null,
|
|
|
|
"description": null,
|
|
|
|
"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"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"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": [],
|
|
|
|
"keywords": [],
|
|
|
|
"readme": null,
|
|
|
|
"repository": null,
|
|
|
|
"edition": "2015",
|
|
|
|
"links": null
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"workspace_members": [
|
|
|
|
"foo 0.0.1 (path+file://[..]/foo)"
|
|
|
|
],
|
|
|
|
"resolve": "{...}",
|
|
|
|
"target_directory": "[..]/foo/target",
|
|
|
|
"version": 1,
|
|
|
|
"workspace_root": "[..]/foo"
|
|
|
|
}
|
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() {
|
2019-04-27 23:01:43 +00:00
|
|
|
let config = paths::root().join(".cargo/config");
|
|
|
|
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
|
|
|
|
|
|
|
registry::init();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "relative"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.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
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr(&format!(
|
|
|
|
"\
|
|
|
|
[UPDATING] `{reg}` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] bar v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
|
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
|
|
|
|
",
|
|
|
|
reg = registry::alt_registry_path().to_str().unwrap()
|
|
|
|
))
|
|
|
|
.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() {
|
|
|
|
let config = paths::root().join(".cargo/config");
|
|
|
|
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
|
|
|
|
|
|
|
registry::init();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
version = "0.0.1"
|
|
|
|
registry = "relative"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.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
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr(&format!(
|
|
|
|
"\
|
|
|
|
error: failed to parse manifest at `{root}/foo/Cargo.toml`
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|