2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for local-registry sources.
|
|
|
|
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::paths::{self, CargoPathExt};
|
|
|
|
use cargo_test_support::registry::{registry_path, Package};
|
|
|
|
use cargo_test_support::{basic_manifest, project, t};
|
2020-04-17 04:10:11 +00:00
|
|
|
use std::fs;
|
2016-02-05 23:14:17 +00:00
|
|
|
|
|
|
|
fn setup() {
|
|
|
|
let root = paths::root();
|
|
|
|
t!(fs::create_dir(&root.join(".cargo")));
|
2020-04-17 04:10:11 +00:00
|
|
|
t!(fs::write(
|
2024-01-26 19:40:46 +00:00
|
|
|
root.join(".cargo/config.toml"),
|
2020-04-17 04:10:11 +00:00
|
|
|
r#"
|
|
|
|
[source.crates-io]
|
|
|
|
registry = 'https://wut'
|
|
|
|
replace-with = 'my-awesome-local-registry'
|
|
|
|
|
|
|
|
[source.my-awesome-local-registry]
|
|
|
|
local-registry = 'registry'
|
|
|
|
"#
|
2018-03-14 15:17:44 +00:00
|
|
|
));
|
2016-02-05 23:14:17 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-05 23:14:17 +00:00
|
|
|
fn simple() {
|
|
|
|
setup();
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.0.1")
|
2018-03-14 15:17:44 +00:00
|
|
|
.local(true)
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.0.1"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-08-28 09:20:03 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
"extern crate bar; pub fn foo() { bar::bar(); }",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-07-20 17:41:44 +00:00
|
|
|
[UNPACKING] bar v0.0.1 ([..])
|
|
|
|
[COMPILING] bar v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2016-07-05 17:28:51 +00:00
|
|
|
[FINISHED] [..]
|
2016-02-05 23:14:17 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build").with_stderr("[FINISHED] [..]").run();
|
|
|
|
p.cargo("test").run();
|
2016-02-05 23:14:17 +00:00
|
|
|
}
|
|
|
|
|
2022-05-20 18:24:22 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn not_found() {
|
|
|
|
setup();
|
|
|
|
// Publish a package so that the directory hierarchy is created.
|
|
|
|
// Note, however, that we declare a dependency on baZ.
|
|
|
|
Package::new("bar", "0.0.1").local(true).publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2022-05-20 18:24:22 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
baz = "0.0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"extern crate baz; pub fn foo() { baz::bar(); }",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
2023-02-16 00:02:48 +00:00
|
|
|
p.cargo("check")
|
2022-05-20 18:24:22 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] no matching package named `baz` found
|
|
|
|
location searched: registry `crates-io`
|
|
|
|
required by package `foo v0.0.1 ([..]/foo)`
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-03-13 05:19:55 +00:00
|
|
|
fn depend_on_yanked() {
|
|
|
|
setup();
|
|
|
|
Package::new("bar", "0.0.1").local(true).publish();
|
|
|
|
|
|
|
|
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 = "0.0.1"
|
|
|
|
"#,
|
2019-03-13 05:19:55 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
// Run cargo to create lock file.
|
|
|
|
p.cargo("check").run();
|
|
|
|
|
|
|
|
registry_path().join("index").join("3").rm_rf();
|
|
|
|
Package::new("bar", "0.0.1")
|
|
|
|
.local(true)
|
|
|
|
.yanked(true)
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-05 23:14:17 +00:00
|
|
|
fn multiple_versions() {
|
|
|
|
setup();
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.0.1").local(true).publish();
|
|
|
|
Package::new("bar", "0.1.0")
|
2018-03-14 15:17:44 +00:00
|
|
|
.local(true)
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-08-28 09:20:03 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
"extern crate bar; pub fn foo() { bar::bar(); }",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2023-02-16 00:02:48 +00:00
|
|
|
p.cargo("check")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-07-20 17:41:44 +00:00
|
|
|
[UNPACKING] bar v0.1.0 ([..])
|
2023-02-16 00:02:48 +00:00
|
|
|
[CHECKING] bar v0.1.0
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2016-07-05 17:28:51 +00:00
|
|
|
[FINISHED] [..]
|
2016-02-05 23:14:17 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.2.0")
|
2018-03-14 15:17:44 +00:00
|
|
|
.local(true)
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("update -v")
|
|
|
|
.with_stderr("[UPDATING] bar v0.1.0 -> v0.2.0")
|
|
|
|
.run();
|
2016-02-05 23:14:17 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-05 23:14:17 +00:00
|
|
|
fn multiple_names() {
|
|
|
|
setup();
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.0.1")
|
2018-03-14 15:17:44 +00:00
|
|
|
.local(true)
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("baz", "0.1.0")
|
2018-03-14 15:17:44 +00:00
|
|
|
.local(true)
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn baz() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
baz = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
extern crate bar;
|
|
|
|
extern crate baz;
|
|
|
|
pub fn foo() {
|
|
|
|
bar::bar();
|
|
|
|
baz::baz();
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2023-02-16 00:02:48 +00:00
|
|
|
p.cargo("check")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-02-05 23:14:17 +00:00
|
|
|
[UNPACKING] [..]
|
|
|
|
[UNPACKING] [..]
|
2023-02-16 00:02:48 +00:00
|
|
|
[CHECKING] [..]
|
|
|
|
[CHECKING] [..]
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2016-07-05 17:28:51 +00:00
|
|
|
[FINISHED] [..]
|
2016-02-05 23:14:17 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-05 23:14:17 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-05 23:14:17 +00:00
|
|
|
fn interdependent() {
|
|
|
|
setup();
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.0.1")
|
2018-03-14 15:17:44 +00:00
|
|
|
.local(true)
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("baz", "0.1.0")
|
2018-03-14 15:17:44 +00:00
|
|
|
.local(true)
|
2018-07-20 17:41:44 +00:00
|
|
|
.dep("bar", "*")
|
|
|
|
.file("src/lib.rs", "extern crate bar; pub fn baz() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
baz = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
extern crate bar;
|
|
|
|
extern crate baz;
|
|
|
|
pub fn foo() {
|
|
|
|
bar::bar();
|
|
|
|
baz::baz();
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2023-02-16 00:02:48 +00:00
|
|
|
p.cargo("check")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-02-05 23:14:17 +00:00
|
|
|
[UNPACKING] [..]
|
|
|
|
[UNPACKING] [..]
|
2023-02-16 00:02:48 +00:00
|
|
|
[CHECKING] bar v0.0.1
|
|
|
|
[CHECKING] baz v0.1.0
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2016-07-05 17:28:51 +00:00
|
|
|
[FINISHED] [..]
|
2016-02-05 23:14:17 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-05 23:14:17 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-05 23:14:17 +00:00
|
|
|
fn path_dep_rewritten() {
|
|
|
|
setup();
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.0.1")
|
2018-03-14 15:17:44 +00:00
|
|
|
.local(true)
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("baz", "0.1.0")
|
2018-03-14 15:17:44 +00:00
|
|
|
.local(true)
|
2018-07-20 17:41:44 +00:00
|
|
|
.dep("bar", "*")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2018-07-20 17:41:44 +00:00
|
|
|
name = "baz"
|
2016-02-05 23:14:17 +00:00
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
2018-07-20 17:41:44 +00:00
|
|
|
bar = { path = "bar", version = "*" }
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "extern crate bar; pub fn baz() {}")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("bar/src/lib.rs", "pub fn bar() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
baz = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
extern crate bar;
|
|
|
|
extern crate baz;
|
|
|
|
pub fn foo() {
|
|
|
|
bar::bar();
|
|
|
|
baz::baz();
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2023-02-16 00:02:48 +00:00
|
|
|
p.cargo("check")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-02-05 23:14:17 +00:00
|
|
|
[UNPACKING] [..]
|
|
|
|
[UNPACKING] [..]
|
2023-02-16 00:02:48 +00:00
|
|
|
[CHECKING] bar v0.0.1
|
|
|
|
[CHECKING] baz v0.1.0
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2016-07-05 17:28:51 +00:00
|
|
|
[FINISHED] [..]
|
2016-02-05 23:14:17 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-05 23:14:17 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-05 23:14:17 +00:00
|
|
|
fn invalid_dir_bad() {
|
|
|
|
setup();
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
2024-01-26 19:40:46 +00:00
|
|
|
".cargo/config.toml",
|
2018-03-14 15:17:44 +00:00
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[source.crates-io]
|
|
|
|
registry = 'https://wut'
|
|
|
|
replace-with = 'my-awesome-local-directory'
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[source.my-awesome-local-directory]
|
|
|
|
local-registry = '/path/to/nowhere'
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2023-02-16 00:02:48 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2020-02-27 16:17:18 +00:00
|
|
|
[ERROR] failed to get `bar` as a dependency of package `foo v0.0.1 [..]`
|
2020-02-25 18:17:11 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to load source for dependency `bar`
|
2016-02-05 23:14:17 +00:00
|
|
|
|
|
|
|
Caused by:
|
2021-06-27 19:18:36 +00:00
|
|
|
Unable to update registry `crates-io`
|
2016-02-05 23:14:17 +00:00
|
|
|
|
|
|
|
Caused by:
|
2021-06-27 19:18:36 +00:00
|
|
|
failed to update replaced source registry `crates-io`
|
2016-02-05 23:14:17 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
local registry path is not a directory: [..]path[..]to[..]nowhere
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-05 23:14:17 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-05 23:14:17 +00:00
|
|
|
fn different_directory_replacing_the_registry_is_bad() {
|
|
|
|
setup();
|
|
|
|
|
|
|
|
// Move our test's .cargo/config to a temporary location and publish a
|
|
|
|
// registry package we're going to use first.
|
|
|
|
let config = paths::root().join(".cargo");
|
|
|
|
let config_tmp = paths::root().join(".cargo-old");
|
|
|
|
t!(fs::rename(&config, &config_tmp));
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
|
|
|
// Generate a lock file against the crates.io registry
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.0.1").publish();
|
2023-02-16 00:02:48 +00:00
|
|
|
p.cargo("check").run();
|
2016-02-05 23:14:17 +00:00
|
|
|
|
|
|
|
// Switch back to our directory source, and now that we're replacing
|
|
|
|
// crates.io make sure that this fails because we're replacing with a
|
|
|
|
// different checksum
|
|
|
|
config.rm_rf();
|
|
|
|
t!(fs::rename(&config_tmp, &config));
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.0.1")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file("src/lib.rs", "invalid")
|
|
|
|
.local(true)
|
|
|
|
.publish();
|
|
|
|
|
2023-02-16 00:02:48 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-07-20 17:41:44 +00:00
|
|
|
[ERROR] checksum for `bar v0.0.1` changed between lock files
|
2016-02-05 23:14:17 +00:00
|
|
|
|
|
|
|
this could be indicative of a few possible errors:
|
|
|
|
|
|
|
|
* the lock file is corrupt
|
2019-02-03 04:01:23 +00:00
|
|
|
* a replacement source in use (e.g., a mirror) returned a different checksum
|
2016-02-05 23:14:17 +00:00
|
|
|
* the source itself may be corrupt in one way or another
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
unable to verify that `bar v0.0.1` is the same as when the lockfile was generated
|
2016-02-05 23:14:17 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-05 23:14:17 +00:00
|
|
|
}
|
2016-09-13 02:26:16 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-09-13 02:26:16 +00:00
|
|
|
fn crates_io_registry_url_is_optional() {
|
|
|
|
let root = paths::root();
|
|
|
|
t!(fs::create_dir(&root.join(".cargo")));
|
2020-04-17 04:10:11 +00:00
|
|
|
t!(fs::write(
|
2024-01-26 19:40:46 +00:00
|
|
|
root.join(".cargo/config.toml"),
|
2020-04-17 04:10:11 +00:00
|
|
|
r#"
|
|
|
|
[source.crates-io]
|
|
|
|
replace-with = 'my-awesome-local-registry'
|
|
|
|
|
|
|
|
[source.my-awesome-local-registry]
|
|
|
|
local-registry = 'registry'
|
|
|
|
"#
|
2018-03-14 15:17:44 +00:00
|
|
|
));
|
2016-09-13 02:26:16 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.0.1")
|
2018-03-14 15:17:44 +00:00
|
|
|
.local(true)
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2016-09-13 02:26:16 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.0.1"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-08-28 09:20:03 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
"extern crate bar; pub fn foo() { bar::bar(); }",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-09-13 02:26:16 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-07-20 17:41:44 +00:00
|
|
|
[UNPACKING] bar v0.0.1 ([..])
|
|
|
|
[COMPILING] bar v0.0.1
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
2016-09-13 02:26:16 +00:00
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build").with_stderr("[FINISHED] [..]").run();
|
|
|
|
p.cargo("test").run();
|
2016-09-13 02:26:16 +00:00
|
|
|
}
|