2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for directory sources.
|
|
|
|
|
2016-07-05 17:28:51 +00:00
|
|
|
use std::collections::HashMap;
|
2020-04-17 04:10:11 +00:00
|
|
|
use std::fs;
|
2016-07-05 17:28:51 +00:00
|
|
|
use std::str;
|
|
|
|
|
2018-12-11 01:55:13 +00:00
|
|
|
use serde::Serialize;
|
|
|
|
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::cargo_process;
|
|
|
|
use cargo_test_support::git;
|
|
|
|
use cargo_test_support::paths;
|
|
|
|
use cargo_test_support::registry::{cksum, Package};
|
2019-09-12 19:52:46 +00:00
|
|
|
use cargo_test_support::{basic_manifest, project, t, ProjectBuilder};
|
2016-07-05 17:28:51 +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#"
|
2018-08-23 18:51:05 +00:00
|
|
|
[source.crates-io]
|
|
|
|
replace-with = 'my-awesome-local-registry'
|
2016-07-05 17:28:51 +00:00
|
|
|
|
2018-08-23 18:51:05 +00:00
|
|
|
[source.my-awesome-local-registry]
|
|
|
|
directory = 'index'
|
|
|
|
"#
|
2018-03-14 15:17:44 +00:00
|
|
|
));
|
2016-07-05 17:28:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct VendorPackage {
|
|
|
|
p: Option<ProjectBuilder>,
|
|
|
|
cksum: Checksum,
|
|
|
|
}
|
|
|
|
|
2017-06-08 20:08:59 +00:00
|
|
|
#[derive(Serialize)]
|
2016-07-05 17:28:51 +00:00
|
|
|
struct Checksum {
|
2017-05-04 03:33:28 +00:00
|
|
|
package: Option<String>,
|
2016-07-05 17:28:51 +00:00
|
|
|
files: HashMap<String, String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl VendorPackage {
|
|
|
|
fn new(name: &str) -> VendorPackage {
|
|
|
|
VendorPackage {
|
2018-07-20 11:47:47 +00:00
|
|
|
p: Some(project().at(&format!("index/{}", name))),
|
2016-07-05 17:28:51 +00:00
|
|
|
cksum: Checksum {
|
2017-05-04 03:33:28 +00:00
|
|
|
package: Some(String::new()),
|
2016-07-05 17:28:51 +00:00
|
|
|
files: HashMap::new(),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn file(&mut self, name: &str, contents: &str) -> &mut VendorPackage {
|
|
|
|
self.p = Some(self.p.take().unwrap().file(name, contents));
|
2018-03-14 15:17:44 +00:00
|
|
|
self.cksum
|
|
|
|
.files
|
|
|
|
.insert(name.to_string(), cksum(contents.as_bytes()));
|
2016-07-05 17:28:51 +00:00
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2017-05-04 03:33:28 +00:00
|
|
|
fn disable_checksum(&mut self) -> &mut VendorPackage {
|
|
|
|
self.cksum.package = None;
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2018-07-24 12:59:42 +00:00
|
|
|
fn no_manifest(mut self) -> Self {
|
|
|
|
self.p = self.p.map(|pb| pb.no_manifest());
|
|
|
|
self
|
|
|
|
}
|
|
|
|
|
2016-07-05 17:28:51 +00:00
|
|
|
fn build(&mut self) {
|
|
|
|
let p = self.p.take().unwrap();
|
2017-06-08 20:08:59 +00:00
|
|
|
let json = serde_json::to_string(&self.cksum).unwrap();
|
2016-07-05 17:28:51 +00:00
|
|
|
let p = p.file(".cargo-checksum.json", &json);
|
2017-07-22 03:12:21 +00:00
|
|
|
let _ = p.build();
|
2016-07-05 17:28:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-07-05 17:28:51 +00:00
|
|
|
fn simple() {
|
|
|
|
setup();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
VendorPackage::new("bar")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2016-07-05 17:28:51 +00:00
|
|
|
.build();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2016-07-05 17:28:51 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
"#,
|
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-07-05 17:28:51 +00:00
|
|
|
|
2023-02-15 23:02:54 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2023-02-15 23:02:54 +00:00
|
|
|
[CHECKING] bar v0.1.0
|
|
|
|
[CHECKING] foo v0.1.0 ([CWD])
|
2016-07-05 17:28:51 +00:00
|
|
|
[FINISHED] [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-07-05 17:28:51 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-03-02 02:19:43 +00:00
|
|
|
fn simple_install() {
|
|
|
|
setup();
|
|
|
|
|
|
|
|
VendorPackage::new("foo")
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
VendorPackage::new("bar")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2017-03-02 02:19:43 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
foo = "0.0.1"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-08-28 09:20:03 +00:00
|
|
|
"src/main.rs",
|
|
|
|
"extern crate foo; pub fn main() { foo::foo(); }",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2017-03-02 02:19:43 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
cargo_process("install bar")
|
|
|
|
.with_stderr(
|
2019-03-31 00:33:35 +00:00
|
|
|
"\
|
|
|
|
[INSTALLING] bar v0.1.0
|
|
|
|
[COMPILING] foo v0.0.1
|
|
|
|
[COMPILING] bar v0.1.0
|
|
|
|
[FINISHED] release [optimized] target(s) in [..]s
|
|
|
|
[INSTALLING] [..]bar[..]
|
|
|
|
[INSTALLED] package `bar v0.1.0` (executable `bar[EXE]`)
|
|
|
|
[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-03-02 02:19:43 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-03-02 02:19:43 +00:00
|
|
|
fn simple_install_fail() {
|
|
|
|
setup();
|
|
|
|
|
|
|
|
VendorPackage::new("foo")
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
VendorPackage::new("bar")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
|
|
|
baz = "9.8.7"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-08-28 09:20:03 +00:00
|
|
|
"src/main.rs",
|
|
|
|
"extern crate foo; pub fn main() { foo::foo(); }",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
|
|
|
|
cargo_process("install bar")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
" Installing bar v0.1.0
|
2023-06-05 09:27:31 +00:00
|
|
|
error: failed to compile `bar v0.1.0`, intermediate artifacts can be found at `[..]`.
|
|
|
|
To reuse those artifacts with a future compilation, set the environment variable \
|
2023-06-04 16:31:06 +00:00
|
|
|
`CARGO_TARGET_DIR` to that path.
|
2017-03-02 02:19:43 +00:00
|
|
|
|
|
|
|
Caused by:
|
2021-07-10 14:07:29 +00:00
|
|
|
no matching package found
|
|
|
|
searched package name: `baz`
|
|
|
|
perhaps you meant: bar or foo
|
2021-06-27 19:18:36 +00:00
|
|
|
location searched: registry `crates-io`
|
2020-06-25 15:25:52 +00:00
|
|
|
required by package `bar v0.1.0`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-03-02 02:19:43 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-03-02 02:19:43 +00:00
|
|
|
fn install_without_feature_dep() {
|
|
|
|
setup();
|
|
|
|
|
|
|
|
VendorPackage::new("foo")
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
VendorPackage::new("bar")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2017-03-02 02:19:43 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
foo = "0.0.1"
|
|
|
|
baz = { version = "9.8.7", optional = true }
|
2017-03-02 02:19:43 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[features]
|
|
|
|
wantbaz = ["baz"]
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-08-28 09:20:03 +00:00
|
|
|
"src/main.rs",
|
|
|
|
"extern crate foo; pub fn main() { foo::foo(); }",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2017-03-02 02:19:43 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
cargo_process("install bar")
|
|
|
|
.with_stderr(
|
2019-03-31 00:33:35 +00:00
|
|
|
"\
|
|
|
|
[INSTALLING] bar v0.1.0
|
|
|
|
[COMPILING] foo v0.0.1
|
|
|
|
[COMPILING] bar v0.1.0
|
|
|
|
[FINISHED] release [optimized] target(s) in [..]s
|
|
|
|
[INSTALLING] [..]bar[..]
|
|
|
|
[INSTALLED] package `bar v0.1.0` (executable `bar[EXE]`)
|
|
|
|
[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-03-02 02:19:43 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-07-05 17:28:51 +00:00
|
|
|
fn not_there() {
|
|
|
|
setup();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let _ = project().at("index").build();
|
2016-07-05 17:28:51 +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#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2016-07-05 17:28:51 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
"#,
|
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();
|
2018-08-28 09:20:03 +00:00
|
|
|
|
2023-02-15 23:02:54 +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: no matching package named `bar` found
|
2016-07-05 17:28:51 +00:00
|
|
|
location searched: [..]
|
2018-07-20 17:41:44 +00:00
|
|
|
required by package `foo v0.1.0 ([..])`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-07-05 17:28:51 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-07-05 17:28:51 +00:00
|
|
|
fn multiple() {
|
|
|
|
setup();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
VendorPackage::new("bar-0.1.0")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2016-07-05 17:28:51 +00:00
|
|
|
.file(".cargo-checksum", "")
|
|
|
|
.build();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
VendorPackage::new("bar-0.2.0")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.2.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2016-07-05 17:28:51 +00:00
|
|
|
.file(".cargo-checksum", "")
|
|
|
|
.build();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2016-07-05 17:28:51 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
"#,
|
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-07-05 17:28:51 +00:00
|
|
|
|
2023-02-15 23:02:54 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2023-02-15 23:02:54 +00:00
|
|
|
[CHECKING] bar v0.1.0
|
|
|
|
[CHECKING] foo v0.1.0 ([CWD])
|
2016-07-05 17:28:51 +00:00
|
|
|
[FINISHED] [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-07-05 17:28:51 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-07-05 17:28:51 +00:00
|
|
|
fn crates_io_then_directory() {
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2016-07-05 17:28:51 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
"#,
|
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-07-05 17:28:51 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let cksum = Package::new("bar", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub fn bar() -> u32 { 0 }")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2016-07-05 17:28:51 +00:00
|
|
|
|
2023-02-15 23:02:54 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `[..]` index
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] bar v0.1.0 ([..])
|
2023-02-15 23:02:54 +00:00
|
|
|
[CHECKING] bar v0.1.0
|
|
|
|
[CHECKING] foo v0.1.0 ([CWD])
|
2016-07-05 17:28:51 +00:00
|
|
|
[FINISHED] [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-07-05 17:28:51 +00:00
|
|
|
|
|
|
|
setup();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let mut v = VendorPackage::new("bar");
|
2018-07-24 22:35:01 +00:00
|
|
|
v.file("Cargo.toml", &basic_manifest("bar", "0.1.0"));
|
2018-07-20 17:41:44 +00:00
|
|
|
v.file("src/lib.rs", "pub fn bar() -> u32 { 1 }");
|
2017-05-04 03:33:28 +00:00
|
|
|
v.cksum.package = Some(cksum);
|
2016-07-05 17:28:51 +00:00
|
|
|
v.build();
|
|
|
|
|
2023-02-15 23:02:54 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2023-02-15 23:02:54 +00:00
|
|
|
[CHECKING] bar v0.1.0
|
|
|
|
[CHECKING] foo v0.1.0 ([CWD])
|
2016-07-05 17:28:51 +00:00
|
|
|
[FINISHED] [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-07-05 17:28:51 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-07-05 17:28:51 +00:00
|
|
|
fn crates_io_then_bad_checksum() {
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2016-07-05 17:28:51 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-07-05 17:28:51 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
2016-07-05 17:28:51 +00:00
|
|
|
|
2023-02-15 23:02:54 +00:00
|
|
|
p.cargo("check").run();
|
2016-07-05 17:28:51 +00:00
|
|
|
setup();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
VendorPackage::new("bar")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2016-07-05 17:28:51 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:02:54 +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.1.0` changed between lock files
|
2016-07-05 17:28:51 +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-07-05 17:28:51 +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.1.0` is the same as when the lockfile was generated
|
2016-07-05 17:28:51 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-07-05 17:28:51 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-07-05 17:28:51 +00:00
|
|
|
fn bad_file_checksum() {
|
|
|
|
setup();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
VendorPackage::new("bar")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2016-07-05 17:28:51 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2020-04-17 04:10:11 +00:00
|
|
|
t!(fs::write(
|
|
|
|
paths::root().join("index/bar/src/lib.rs"),
|
|
|
|
"fn bar() -> u32 { 0 }"
|
|
|
|
));
|
2016-07-05 17:28:51 +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#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2016-07-05 17:28:51 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-07-05 17:28:51 +00:00
|
|
|
|
2023-02-15 23:02:54 +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
|
|
|
"\
|
2016-07-05 17:28:51 +00:00
|
|
|
error: the listed checksum of `[..]lib.rs` has changed:
|
|
|
|
expected: [..]
|
|
|
|
actual: [..]
|
|
|
|
|
|
|
|
directory sources are not intended to be edited, if modifications are \
|
2021-06-02 10:28:52 +00:00
|
|
|
required then it is recommended that `[patch]` is used with a forked copy of \
|
2016-07-05 17:28:51 +00:00
|
|
|
the source
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-07-05 17:28:51 +00:00
|
|
|
}
|
2017-04-04 23:28:42 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-04-04 23:28:42 +00:00
|
|
|
fn only_dot_files_ok() {
|
|
|
|
setup();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
VendorPackage::new("bar")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2017-04-04 23:28:42 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
VendorPackage::new("foo")
|
|
|
|
.no_manifest()
|
|
|
|
.file(".bar", "")
|
|
|
|
.build();
|
2017-04-04 23:28:42 +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#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2017-04-04 23:28:42 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-04-04 23:28:42 +00:00
|
|
|
|
2023-02-15 23:02:54 +00:00
|
|
|
p.cargo("check").run();
|
2017-04-04 23:28:42 +00:00
|
|
|
}
|
2017-05-04 03:33:28 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-01-24 18:04:47 +00:00
|
|
|
fn random_files_ok() {
|
|
|
|
setup();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
VendorPackage::new("bar")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-01-24 18:04:47 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
2018-07-20 17:41:44 +00:00
|
|
|
VendorPackage::new("foo")
|
2018-07-24 12:59:42 +00:00
|
|
|
.no_manifest()
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("bar", "")
|
2018-01-24 18:04:47 +00:00
|
|
|
.file("../test", "")
|
|
|
|
.build();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2018-01-24 18:04:47 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-01-24 18:04:47 +00:00
|
|
|
.build();
|
|
|
|
|
2023-02-15 23:02:54 +00:00
|
|
|
p.cargo("check").run();
|
2018-01-24 18:04:47 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-05-04 03:33:28 +00:00
|
|
|
fn git_lock_file_doesnt_change() {
|
|
|
|
let git = git::new("git", |p| {
|
2018-07-24 22:35:01 +00:00
|
|
|
p.file("Cargo.toml", &basic_manifest("git", "0.5.0"))
|
2018-08-28 09:20:03 +00:00
|
|
|
.file("src/lib.rs", "")
|
2019-08-13 05:25:36 +00:00
|
|
|
});
|
2017-05-04 03:33:28 +00:00
|
|
|
|
|
|
|
VendorPackage::new("git")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("git", "0.5.0"))
|
2017-05-04 03:33:28 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.disable_checksum()
|
|
|
|
.build();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
git = {{ git = '{0}' }}
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
git.url()
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-05-04 03:33:28 +00:00
|
|
|
|
2023-02-15 23:02:54 +00:00
|
|
|
p.cargo("check").run();
|
2017-05-04 03:33:28 +00:00
|
|
|
|
2020-04-17 04:10:11 +00:00
|
|
|
let lock1 = p.read_lockfile();
|
2017-05-04 03:33:28 +00:00
|
|
|
|
|
|
|
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"),
|
2019-03-27 00:53:53 +00:00
|
|
|
format!(
|
2018-03-14 15:17:44 +00:00
|
|
|
r#"
|
2020-04-17 04:10:11 +00:00
|
|
|
[source.my-git-repo]
|
|
|
|
git = '{}'
|
|
|
|
replace-with = 'my-awesome-local-registry'
|
2017-05-04 03:33:28 +00:00
|
|
|
|
2020-04-17 04:10:11 +00:00
|
|
|
[source.my-awesome-local-registry]
|
|
|
|
directory = 'index'
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
git.url()
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
2018-08-28 09:20:03 +00:00
|
|
|
));
|
2018-03-14 15:17:44 +00:00
|
|
|
|
2023-02-15 23:02:54 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2023-02-15 23:02:54 +00:00
|
|
|
[CHECKING] [..]
|
|
|
|
[CHECKING] [..]
|
2017-05-04 03:33:28 +00:00
|
|
|
[FINISHED] [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-05-04 03:33:28 +00:00
|
|
|
|
2020-04-17 04:10:11 +00:00
|
|
|
let lock2 = p.read_lockfile();
|
2018-02-23 23:27:53 +00:00
|
|
|
assert_eq!(lock1, lock2, "lock files changed");
|
2017-05-04 03:33:28 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-05-04 03:33:28 +00:00
|
|
|
fn git_override_requires_lockfile() {
|
|
|
|
VendorPackage::new("git")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("git", "0.5.0"))
|
2017-05-04 03:33:28 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.disable_checksum()
|
|
|
|
.build();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
git = { git = 'https://example.com/' }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-05-04 03:33:28 +00:00
|
|
|
|
|
|
|
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.my-git-repo]
|
|
|
|
git = 'https://example.com/'
|
|
|
|
replace-with = 'my-awesome-local-registry'
|
|
|
|
|
|
|
|
[source.my-awesome-local-registry]
|
|
|
|
directory = 'index'
|
|
|
|
"#
|
2018-03-14 15:17:44 +00:00
|
|
|
));
|
2017-05-04 03:33:28 +00:00
|
|
|
|
2023-02-15 23:02:54 +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 `git` 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 `git`
|
2017-05-04 03:33:28 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
Unable to update [..]
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
the source my-git-repo requires a lock file to be present first before it can be
|
2020-06-25 15:25:52 +00:00
|
|
|
used against vendored source code
|
2017-05-04 03:33:28 +00:00
|
|
|
|
2020-06-25 15:25:52 +00:00
|
|
|
remove the source replacement configuration, generate a lock file, and then
|
|
|
|
restore the source replacement configuration to continue the build
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-05-04 03:33:28 +00:00
|
|
|
}
|
2018-08-23 18:51:05 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-08-23 18:51:05 +00:00
|
|
|
fn workspace_different_locations() {
|
|
|
|
let p = project()
|
|
|
|
.no_manifest()
|
|
|
|
.file(
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = 'foo'
|
|
|
|
version = '0.1.0'
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
baz = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("foo/src/lib.rs", "")
|
2018-08-23 18:51:05 +00:00
|
|
|
.file("foo/vendor/baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
|
|
|
.file("foo/vendor/baz/src/lib.rs", "")
|
|
|
|
.file("foo/vendor/baz/.cargo-checksum.json", "{\"files\":{}}")
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = 'bar'
|
|
|
|
version = '0.1.0'
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
baz = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("bar/src/lib.rs", "")
|
2018-08-23 18:51:05 +00:00
|
|
|
.file(
|
2024-01-26 19:40:46 +00:00
|
|
|
".cargo/config.toml",
|
2018-08-23 18:51:05 +00:00
|
|
|
r#"
|
|
|
|
[build]
|
|
|
|
target-dir = './target'
|
|
|
|
|
|
|
|
[source.crates-io]
|
|
|
|
replace-with = 'my-awesome-local-registry'
|
|
|
|
|
|
|
|
[source.my-awesome-local-registry]
|
|
|
|
directory = 'foo/vendor'
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-08-23 18:51:05 +00:00
|
|
|
|
2023-02-15 23:02:54 +00:00
|
|
|
p.cargo("check").cwd("foo").run();
|
|
|
|
p.cargo("check")
|
2019-03-20 23:34:56 +00:00
|
|
|
.cwd("bar")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-08-23 18:51:05 +00:00
|
|
|
"\
|
2023-02-15 23:02:54 +00:00
|
|
|
[CHECKING] bar [..]
|
2018-08-23 18:51:05 +00:00
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-08-23 18:51:05 +00:00
|
|
|
}
|
2018-09-29 21:37:03 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-09-29 21:37:03 +00:00
|
|
|
fn version_missing() {
|
|
|
|
setup();
|
|
|
|
|
|
|
|
VendorPackage::new("foo")
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
VendorPackage::new("bar")
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "2"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
cargo_process("install bar")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[INSTALLING] bar v0.1.0
|
2023-06-05 09:27:31 +00:00
|
|
|
error: failed to compile [..], intermediate artifacts can be found at `[..]`.
|
|
|
|
To reuse those artifacts with a future compilation, set the environment variable \
|
|
|
|
`CARGO_TARGET_DIR` to that path.
|
2018-09-29 21:37:03 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to select a version for the requirement `foo = \"^2\"`
|
|
|
|
candidate versions found which didn't match: 0.0.1
|
|
|
|
location searched: directory source `[..] (which is replacing registry `[..]`)
|
2020-06-25 15:25:52 +00:00
|
|
|
required by package `bar v0.1.0`
|
|
|
|
perhaps a crate was updated and forgotten to be re-vendored?
|
2018-09-29 21:37:03 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.with_status(101)
|
|
|
|
.run();
|
|
|
|
}
|