2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for some invalid .cargo/config files.
|
|
|
|
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::registry::Package;
|
2019-11-24 17:43:59 +00:00
|
|
|
use cargo_test_support::{basic_manifest, project, rustc_host};
|
2015-01-14 17:58:43 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn bad1() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2015-01-14 17:58:43 +00:00
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[target]
|
|
|
|
nonexistent-target = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v --target=nonexistent-target")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2019-09-27 19:29:01 +00:00
|
|
|
[ERROR] invalid configuration for key `target.nonexistent-target`
|
|
|
|
expected a table, but found a string for `[..]` in [..]config
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-01-14 17:58:43 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn bad2() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2015-01-14 17:58:43 +00:00
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[http]
|
|
|
|
proxy = 3.0
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-05-03 11:05:21 +00:00
|
|
|
[ERROR] could not load Cargo configuration
|
2015-01-14 17:58:43 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to load TOML configuration from `[..]config`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to parse key `http`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to parse key `proxy`
|
|
|
|
|
|
|
|
Caused by:
|
2015-01-14 18:11:08 +00:00
|
|
|
found TOML configuration value of unknown type `float`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-01-14 17:58:43 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn bad3() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2015-01-14 17:58:43 +00:00
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[http]
|
|
|
|
proxy = true
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-06-28 17:39:46 +00:00
|
|
|
Package::new("foo", "1.0.0").publish();
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-02-05 23:14:17 +00:00
|
|
|
error: failed to update registry [..]
|
|
|
|
|
|
|
|
Caused by:
|
2018-05-15 04:57:47 +00:00
|
|
|
error in [..]config: `http.proxy` expected a string, but found a boolean
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-01-14 17:58:43 +00:00
|
|
|
|
2021-03-20 08:45:19 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn bad4() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
|
|
|
[cargo-new]
|
|
|
|
vcs = false
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
p.cargo("new -v foo")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] Failed to create package `foo` at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
error in [..]config: `cargo-new.vcs` expected a string, but found a boolean
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-05-11 22:41:15 +00:00
|
|
|
fn bad6() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-05-11 22:41:15 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[http]
|
|
|
|
user-agent = true
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-05-11 22:41:15 +00:00
|
|
|
Package::new("foo", "1.0.0").publish();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("publish -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-05-11 22:41:15 +00:00
|
|
|
"\
|
|
|
|
error: failed to update registry [..]
|
|
|
|
|
|
|
|
Caused by:
|
2018-05-15 04:57:47 +00:00
|
|
|
error in [..]config: `http.user-agent` expected a string, but found a boolean
|
2018-05-11 22:41:15 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-05-11 22:41:15 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn bad_cargo_config_jobs() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[build]
|
|
|
|
jobs = -1
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-07-31 18:58:34 +00:00
|
|
|
"\
|
2018-08-02 09:18:48 +00:00
|
|
|
[ERROR] error in [..].cargo/config: \
|
2020-01-08 22:51:49 +00:00
|
|
|
could not load config key `build.jobs`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
invalid value: integer `-1`, expected u32
|
2018-07-31 18:58:34 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-01-15 08:20:56 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn invalid_global_config() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2015-01-15 19:12:13 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(".cargo/config", "4")
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
2015-01-15 19:12:13 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-05-03 11:05:21 +00:00
|
|
|
[ERROR] could not load Cargo configuration
|
2015-01-15 19:12:13 +00:00
|
|
|
|
|
|
|
Caused by:
|
2017-02-10 20:01:52 +00:00
|
|
|
could not parse TOML configuration in `[..]`
|
2015-01-15 19:12:13 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
could not parse input as TOML
|
|
|
|
|
2017-02-10 20:01:52 +00:00
|
|
|
Caused by:
|
2019-08-13 17:37:40 +00:00
|
|
|
expected an equals, found eof at line 1 column 2
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-02-04 07:27:06 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn bad_cargo_lock() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("Cargo.lock", "[[package]]\nfoo = 92")
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
2015-02-04 07:27:06 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-05-10 23:52:02 +00:00
|
|
|
[ERROR] failed to parse lock file at: [..]Cargo.lock
|
2015-02-04 07:27:06 +00:00
|
|
|
|
|
|
|
Caused by:
|
2017-02-10 20:01:52 +00:00
|
|
|
missing field `name` for key `package`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-08-13 16:25:24 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-08-09 12:14:26 +00:00
|
|
|
fn duplicate_packages_in_cargo_lock() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
2016-08-09 12:14:26 +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
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-08-09 12:14:26 +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-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.lock",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[[package]]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
dependencies = [
|
|
|
|
"bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
|
|
]
|
|
|
|
|
|
|
|
[[package]]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
|
|
|
|
|
[[package]]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-08-09 12:14:26 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-08-09 12:14:26 +00:00
|
|
|
[ERROR] failed to parse lock file at: [..]
|
|
|
|
|
|
|
|
Caused by:
|
2018-07-20 17:41:44 +00:00
|
|
|
package `bar` is specified twice in the lockfile
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-08-09 12:14:26 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-08-09 13:11:20 +00:00
|
|
|
fn bad_source_in_cargo_lock() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
2016-08-09 13:11:20 +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
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-08-09 13:11:20 +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-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.lock",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[[package]]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
dependencies = [
|
|
|
|
"bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
|
|
]
|
|
|
|
|
|
|
|
[[package]]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
source = "You shall not parse"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-08-09 13:11:20 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build --verbose")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-08-09 13:11:20 +00:00
|
|
|
[ERROR] failed to parse lock file at: [..]
|
|
|
|
|
|
|
|
Caused by:
|
2017-02-10 20:01:52 +00:00
|
|
|
invalid source `You shall not parse` for key `package.source`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-08-09 13:11:20 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-08-26 09:34:17 +00:00
|
|
|
fn bad_dependency_in_lockfile() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2016-08-26 09:34:17 +00:00
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.lock",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[[package]]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
dependencies = [
|
|
|
|
"bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
|
|
]
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-08-26 09:34:17 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build").run();
|
2016-08-26 09:34:17 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn bad_git_dependency() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2015-08-13 16:25:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
foo = { git = "file:.." }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-08-13 16:25:24 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-05-14 20:31:11 +00:00
|
|
|
[UPDATING] git repository `file:///`
|
2020-02-27 16:17:18 +00:00
|
|
|
[ERROR] failed to get `foo` as a dependency of package `foo v0.0.0 [..]`
|
2020-02-25 18:17:11 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to load source for dependency `foo`
|
2016-06-28 17:39:46 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
Unable to update file:///
|
2015-08-13 16:25:24 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to clone into: [..]
|
|
|
|
|
|
|
|
Caused by:
|
2017-12-11 12:10:54 +00:00
|
|
|
[..]'file:///' is not a valid local file URI[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-08-15 19:49:09 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn bad_crate_type() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2015-08-15 19:49:09 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[lib]
|
|
|
|
crate-type = ["bad_type", "rlib"]
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-08-15 19:49:09 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
2018-03-21 07:54:15 +00:00
|
|
|
"error: failed to run `rustc` to learn about crate-type bad_type information",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-07 17:37:56 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn malformed_override() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2015-10-07 17:37:56 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[target.x86_64-apple-darwin.freetype]
|
|
|
|
native = {
|
|
|
|
foo: "bar"
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-10-07 17:37:56 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-05-10 23:52:02 +00:00
|
|
|
[ERROR] failed to parse manifest at `[..]`
|
2015-10-07 17:37:56 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
could not parse input as TOML
|
|
|
|
|
2017-02-10 20:01:52 +00:00
|
|
|
Caused by:
|
2020-09-27 00:59:58 +00:00
|
|
|
expected a table key, found a newline at line 8 column 27
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-11-23 00:47:30 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn duplicate_binary_names() {
|
2018-07-20 11:47:47 +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 = "qqq"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = ["A <a@a.a>"]
|
2015-11-23 00:47:30 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[[bin]]
|
|
|
|
name = "e"
|
|
|
|
path = "a.rs"
|
2015-11-23 00:47:30 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[[bin]]
|
|
|
|
name = "e"
|
|
|
|
path = "b.rs"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("a.rs", r#"fn main() -> () {}"#)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("b.rs", r#"fn main() -> () {}"#)
|
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-05-10 23:52:02 +00:00
|
|
|
[ERROR] failed to parse manifest at `[..]`
|
2015-11-23 00:47:30 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
found duplicate binary name e, but all binary targets must have a unique name
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-11-23 00:47:30 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn duplicate_example_names() {
|
2018-07-20 11:47:47 +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 = "qqq"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = ["A <a@a.a>"]
|
2015-11-23 00:47:30 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[[example]]
|
|
|
|
name = "ex"
|
|
|
|
path = "examples/ex.rs"
|
2017-07-22 03:12:21 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[[example]]
|
|
|
|
name = "ex"
|
|
|
|
path = "examples/ex2.rs"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("examples/ex.rs", r#"fn main () -> () {}"#)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("examples/ex2.rs", r#"fn main () -> () {}"#)
|
|
|
|
.build();
|
2015-11-23 00:47:30 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build --example ex")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-05-10 23:52:02 +00:00
|
|
|
[ERROR] failed to parse manifest at `[..]`
|
2015-11-23 00:47:30 +00:00
|
|
|
|
|
|
|
Caused by:
|
2017-07-08 21:55:38 +00:00
|
|
|
found duplicate example name ex, but all example targets must have a unique name
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-11-23 00:47:30 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn duplicate_bench_names() {
|
2018-07-20 11:47:47 +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 = "qqq"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = ["A <a@a.a>"]
|
2017-07-22 03:12:21 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[[bench]]
|
|
|
|
name = "ex"
|
|
|
|
path = "benches/ex.rs"
|
2017-07-22 03:12:21 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[[bench]]
|
|
|
|
name = "ex"
|
|
|
|
path = "benches/ex2.rs"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("benches/ex.rs", r#"fn main () {}"#)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("benches/ex2.rs", r#"fn main () {}"#)
|
|
|
|
.build();
|
2015-11-23 00:47:30 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("bench")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-05-10 23:52:02 +00:00
|
|
|
[ERROR] failed to parse manifest at `[..]`
|
2015-11-23 00:47:30 +00:00
|
|
|
|
|
|
|
Caused by:
|
2017-07-08 21:55:38 +00:00
|
|
|
found duplicate bench name ex, but all bench targets must have a unique name
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-03-17 20:04:33 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn duplicate_deps() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("shim-bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("shim-bar/src/lib.rs", "pub fn a() {}")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("linux-bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("linux-bar/src/lib.rs", "pub fn a() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "qqq"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-03-17 20:04:33 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = { path = "shim-bar" }
|
2016-03-17 20:04:33 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[target.x86_64-unknown-linux-gnu.dependencies]
|
|
|
|
bar = { path = "linux-bar" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", r#"fn main () {}"#)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-03-17 20:04:33 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-05-10 23:52:02 +00:00
|
|
|
[ERROR] failed to parse manifest at `[..]`
|
2016-03-17 20:04:33 +00:00
|
|
|
|
|
|
|
Caused by:
|
2017-01-26 01:18:19 +00:00
|
|
|
Dependency 'bar' has different source paths depending on the build target. Each dependency must \
|
|
|
|
have a single canonical source path irrespective of build target.
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-01-26 01:18:19 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-01-26 01:18:19 +00:00
|
|
|
fn duplicate_deps_diff_sources() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("shim-bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("shim-bar/src/lib.rs", "pub fn a() {}")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("linux-bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("linux-bar/src/lib.rs", "pub fn a() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "qqq"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2017-01-26 01:18:19 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[target.i686-unknown-linux-gnu.dependencies]
|
|
|
|
bar = { path = "shim-bar" }
|
2017-01-26 01:18:19 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[target.x86_64-unknown-linux-gnu.dependencies]
|
|
|
|
bar = { path = "linux-bar" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", r#"fn main () {}"#)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-01-26 01:18:19 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-01-26 01:18:19 +00:00
|
|
|
[ERROR] failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
Dependency 'bar' has different source paths depending on the build target. Each dependency must \
|
|
|
|
have a single canonical source path irrespective of build target.
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-12-19 00:33:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn unused_keys() {
|
2018-07-20 11:47:47 +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 = []
|
2015-12-19 00:33:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[target.foo]
|
|
|
|
bar = "3"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-12-19 00:33:17 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-03-13 22:24:55 +00:00
|
|
|
warning: unused manifest key: target.foo.bar
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.1.0 ([CWD])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-07-09 10:10:24 +00:00
|
|
|
|
2018-07-31 09:13:16 +00:00
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
cargo-features = ["named-profiles"]
|
2019-06-20 15:32:28 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2018-07-31 09:13:16 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.debug]
|
|
|
|
debug = 1
|
|
|
|
inherits = "dev"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-07-31 09:13:16 +00:00
|
|
|
.build();
|
|
|
|
|
2019-09-12 05:22:19 +00:00
|
|
|
p.cargo("build -Z named-profiles")
|
|
|
|
.masquerade_as_nightly_cargo()
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
warning: use `[profile.dev]` to configure debug builds
|
|
|
|
[..]
|
|
|
|
[..]",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
2019-06-20 15:32:28 +00:00
|
|
|
p.cargo("build -Z named-profiles")
|
|
|
|
.masquerade_as_nightly_cargo()
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2018-07-31 09:13:16 +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#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[project]
|
2017-07-09 10:10:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
bulid = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-07-09 10:10:24 +00:00
|
|
|
warning: unused manifest key: project.bulid
|
|
|
|
[COMPILING] foo [..]
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-07-09 10:10:24 +00:00
|
|
|
|
2018-07-31 18:58:34 +00:00
|
|
|
let p = project()
|
|
|
|
.at("bar")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[project]
|
2017-07-09 10:10:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
2017-07-09 10:10:24 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[lib]
|
|
|
|
build = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-07-09 10:10:24 +00:00
|
|
|
warning: unused manifest key: lib.build
|
|
|
|
[COMPILING] foo [..]
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-07-14 16:20:15 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-07-14 16:20:15 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-07-14 16:20:15 +00:00
|
|
|
fn unused_keys_in_virtual_manifest() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-07-14 16:20:15 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
|
|
|
bulid = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
2020-09-27 00:59:58 +00:00
|
|
|
.file("bar/src/lib.rs", "")
|
2018-07-14 16:20:15 +00:00
|
|
|
.build();
|
2019-08-12 12:31:20 +00:00
|
|
|
p.cargo("build --workspace")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-07-14 16:20:15 +00:00
|
|
|
"\
|
2018-11-07 18:43:19 +00:00
|
|
|
[WARNING] [..]/foo/Cargo.toml: unused manifest key: workspace.bulid
|
2018-07-14 16:20:15 +00:00
|
|
|
[COMPILING] bar [..]
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-01-11 16:08:20 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn empty_dependencies() {
|
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.0"
|
|
|
|
authors = []
|
2016-01-11 16:08:20 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = {}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-01-11 16:08:20 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.0.1").publish();
|
2016-01-11 16:08:20 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
2021-07-14 06:09:45 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2021-07-14 06:09:45 +00:00
|
|
|
[ERROR] failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
dependency (bar) specified without providing a local path, Git repository, or version \
|
|
|
|
to use.
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-05-12 18:44:00 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-12 18:44:00 +00:00
|
|
|
fn invalid_toml_historically_allowed_is_warned() {
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-07-25 00:30:32 +00:00
|
|
|
.file(".cargo/config", "[bar] baz = 2")
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
2016-05-12 18:44:00 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-05-12 18:44:00 +00:00
|
|
|
warning: TOML file found which contains invalid syntax and will soon not parse
|
|
|
|
at `[..]config`.
|
|
|
|
|
2019-02-03 04:01:23 +00:00
|
|
|
The TOML spec requires newlines after table definitions (e.g., `[a] b = 1` is
|
2016-05-12 18:44:00 +00:00
|
|
|
invalid), but this file has a table header which does not have a newline after
|
|
|
|
it. A newline needs to be added and this warning will soon become a hard error
|
|
|
|
in the future.
|
2018-07-24 13:01:56 +00:00
|
|
|
[COMPILING] foo v0.0.1 ([..])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-12 18:44:00 +00:00
|
|
|
}
|
2016-08-01 13:36:29 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-08-01 13:36:29 +00:00
|
|
|
fn ambiguous_git_reference() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2016-08-01 13:36:29 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.bar]
|
|
|
|
git = "http://127.0.0.1"
|
|
|
|
branch = "master"
|
|
|
|
tag = "some-tag"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-08-01 13:36:29 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
|
|
|
.with_status(101)
|
2020-12-16 21:10:11 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2020-12-16 21:10:11 +00:00
|
|
|
[ERROR] failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
dependency (bar) specification is ambiguous. Only one of `branch`, `tag` or `rev` is allowed.
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-08-01 13:36:29 +00:00
|
|
|
}
|
|
|
|
|
2020-06-01 17:50:33 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn fragment_in_git_url() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
2020-06-01 17:50:33 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.bar]
|
|
|
|
git = "http://127.0.0.1#foo"
|
|
|
|
"#,
|
2020-06-01 17:50:33 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
|
|
|
"\
|
|
|
|
[WARNING] URL fragment `#foo` in git URL is ignored for dependency (bar). \
|
|
|
|
If you were trying to specify a specific git revision, \
|
|
|
|
use `rev = \"foo\"` in the dependency declaration.
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-03 18:54:07 +00:00
|
|
|
fn bad_source_config1() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2016-02-03 18:54:07 +00:00
|
|
|
.file("src/lib.rs", "")
|
2018-07-25 00:30:32 +00:00
|
|
|
.file(".cargo/config", "[source.foo]")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
2019-11-24 17:43:59 +00:00
|
|
|
.with_stderr("error: no source location specified for `source.foo`, need [..]")
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2016-02-03 18:54:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-03 18:54:07 +00:00
|
|
|
fn bad_source_config2() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[source.crates-io]
|
|
|
|
registry = 'http://example.com'
|
|
|
|
replace-with = 'bar'
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.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.0 [..]`
|
2020-02-25 18:17:11 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to load source for dependency `bar`
|
2016-02-03 18:54:07 +00:00
|
|
|
|
|
|
|
Caused by:
|
2017-08-30 05:55:31 +00:00
|
|
|
Unable to update registry `https://[..]`
|
2016-02-03 18:54:07 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
could not find a configured source with the name `bar` \
|
|
|
|
when attempting to lookup `crates-io` (configuration in [..])
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-03 18:54:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-03 18:54:07 +00:00
|
|
|
fn bad_source_config3() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[source.crates-io]
|
|
|
|
registry = 'https://example.com'
|
|
|
|
replace-with = 'crates-io'
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.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.0 [..]`
|
2020-02-25 18:17:11 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to load source for dependency `bar`
|
2016-02-03 18:54:07 +00:00
|
|
|
|
|
|
|
Caused by:
|
2017-08-30 05:55:31 +00:00
|
|
|
Unable to update registry `https://[..]`
|
2016-02-03 18:54:07 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
detected a cycle of `replace-with` sources, [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-03 18:54:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-03 18:54:07 +00:00
|
|
|
fn bad_source_config4() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[source.crates-io]
|
|
|
|
replace-with = 'bar'
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[source.bar]
|
|
|
|
registry = 'https://example.com'
|
|
|
|
replace-with = 'crates-io'
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.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.0 ([..])`
|
2020-02-25 18:17:11 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to load source for dependency `bar`
|
2016-02-03 18:54:07 +00:00
|
|
|
|
|
|
|
Caused by:
|
2017-08-30 05:55:31 +00:00
|
|
|
Unable to update registry `https://[..]`
|
2016-02-03 18:54:07 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
detected a cycle of `replace-with` sources, the source `crates-io` is \
|
|
|
|
eventually replaced with itself (configuration in [..])
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-03 18:54:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-03 18:54:07 +00:00
|
|
|
fn bad_source_config5() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[source.crates-io]
|
|
|
|
registry = 'https://example.com'
|
|
|
|
replace-with = 'bar'
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[source.bar]
|
|
|
|
registry = 'not a url'
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-02-03 18:54:07 +00:00
|
|
|
error: configuration key `source.bar.registry` specified an invalid URL (in [..])
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
invalid url `not a url`: [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-03 18:54:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-08-01 13:36:29 +00:00
|
|
|
fn both_git_and_path_specified() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let foo = 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.0"
|
|
|
|
authors = []
|
2016-08-01 13:36:29 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.bar]
|
|
|
|
git = "http://127.0.0.1"
|
|
|
|
path = "bar"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-08-01 13:36:29 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
foo.cargo("build -v")
|
|
|
|
.with_status(101)
|
2021-07-15 06:29:11 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2021-07-15 06:29:11 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
dependency (bar) specification is ambiguous. Only one of `git` or `path` is allowed.
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-08-01 13:36:29 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-03 18:54:07 +00:00
|
|
|
fn bad_source_config6() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[source.crates-io]
|
|
|
|
registry = 'https://example.com'
|
|
|
|
replace-with = ['not', 'a', 'string']
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2019-11-24 17:43:59 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2020-01-08 22:51:49 +00:00
|
|
|
"\
|
|
|
|
[ERROR] error in [..]/foo/.cargo/config: could not load config key `source.crates-io.replace-with`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
error in [..]/foo/.cargo/config: `source.crates-io.replace-with` expected a string, but found a array
|
|
|
|
"
|
2018-08-28 09:20:03 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-03 18:54:07 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-08-01 13:36:29 +00:00
|
|
|
fn ignored_git_revision() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let foo = 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.0"
|
|
|
|
authors = []
|
2016-08-01 13:36:29 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.bar]
|
|
|
|
path = "bar"
|
|
|
|
branch = "spam"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-08-01 13:36:29 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
foo.cargo("build -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
2019-07-13 23:00:47 +00:00
|
|
|
"[WARNING] key `branch` is ignored for dependency (bar). \
|
2018-03-14 15:17:44 +00:00
|
|
|
This will be considered an error in future versions",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-08-01 13:36:29 +00:00
|
|
|
}
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-02-03 18:54:07 +00:00
|
|
|
fn bad_source_config7() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[source.foo]
|
|
|
|
registry = 'https://example.com'
|
|
|
|
local-registry = 'file:///another/file'
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-03 18:54:07 +00:00
|
|
|
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
2019-11-24 17:43:59 +00:00
|
|
|
.with_stderr("error: more than one source location specified for `source.foo`")
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn bad_source_config8() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
2019-11-24 17:43:59 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
|
|
|
"#,
|
2019-11-24 17:43:59 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[source.foo]
|
|
|
|
branch = "somebranch"
|
|
|
|
"#,
|
2019-11-24 17:43:59 +00:00
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"[ERROR] source definition `source.foo` specifies `branch`, \
|
|
|
|
but that requires a `git` key to be specified (in [..]/foo/.cargo/config)",
|
|
|
|
)
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2016-02-03 18:54:07 +00:00
|
|
|
}
|
2017-03-03 16:12:12 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-03-03 16:12:12 +00:00
|
|
|
fn bad_dependency() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2017-03-03 16:12:12 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = 3
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-03-03 16:12:12 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-03-03 16:12:12 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
invalid type: integer `3`, expected a version string like [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-03-03 16:12:12 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-03-03 16:12:12 +00:00
|
|
|
fn bad_debuginfo() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
2017-03-03 16:12:12 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.dev]
|
|
|
|
debug = 'a'
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-03-03 16:12:12 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-03-03 16:12:12 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
2021-03-19 23:22:39 +00:00
|
|
|
expected a boolean or an integer for [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-03-03 16:12:12 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-03-03 16:12:12 +00:00
|
|
|
fn bad_opt_level() {
|
2018-07-20 11:47:47 +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.0"
|
|
|
|
authors = []
|
|
|
|
build = 3
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-03-03 16:12:12 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2017-03-03 16:12:12 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
2021-03-19 23:22:39 +00:00
|
|
|
expected a boolean or a string for key [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-03-03 16:12:12 +00:00
|
|
|
}
|
2019-04-01 01:53:54 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-04-01 01:53:54 +00:00
|
|
|
fn warn_semver_metadata() {
|
|
|
|
Package::new("bar", "1.0.0").publish();
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "1.0.0"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "1.0.0+1234"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
p.cargo("check")
|
|
|
|
.with_stderr_contains("[WARNING] version requirement `1.0.0+1234` for dependency `bar`[..]")
|
|
|
|
.run();
|
|
|
|
}
|
2019-11-24 17:43:59 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn bad_target_cfg() {
|
|
|
|
// Invalid type in a StringList.
|
|
|
|
//
|
|
|
|
// The error message is a bit unfortunate here. The type here ends up
|
|
|
|
// being essentially Value<Value<StringList>>, and each layer of "Value"
|
|
|
|
// adds some context to the error message. Also, untagged enums provide
|
|
|
|
// strange error messages. Hopefully most users will be able to untangle
|
|
|
|
// the message.
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
|
|
|
[target.'cfg(not(target_os = "none"))']
|
|
|
|
runner = false
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] error in [..]/foo/.cargo/config: \
|
2021-06-16 17:28:43 +00:00
|
|
|
could not load config key `target.\"cfg(not(target_os = \\\"none\\\"))\".runner`
|
2020-01-08 22:51:49 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
error in [..]/foo/.cargo/config: \
|
2021-06-16 17:28:43 +00:00
|
|
|
could not load config key `target.\"cfg(not(target_os = \\\"none\\\"))\".runner`
|
2020-01-08 22:51:49 +00:00
|
|
|
|
|
|
|
Caused by:
|
2021-06-16 17:28:43 +00:00
|
|
|
invalid configuration for key `target.\"cfg(not(target_os = \\\"none\\\"))\".runner`
|
2020-06-25 15:25:52 +00:00
|
|
|
expected a string or array of strings, but found a boolean for \
|
2021-06-16 17:28:43 +00:00
|
|
|
`target.\"cfg(not(target_os = \\\"none\\\"))\".runner` in [..]/foo/.cargo/config
|
2019-11-24 17:43:59 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn bad_target_links_overrides() {
|
|
|
|
// Invalid parsing of links overrides.
|
|
|
|
//
|
|
|
|
// This error message is terrible. Nothing in the deserialization path is
|
|
|
|
// using config::Value<>, so nothing is able to report the location. I
|
|
|
|
// think this illustrates how the way things break down with how it
|
|
|
|
// currently is designed with serde.
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[target.{}.somelib]
|
|
|
|
rustc-flags = 'foo'
|
|
|
|
"#,
|
|
|
|
rustc_host()
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_status(101)
|
2020-01-02 18:25:54 +00:00
|
|
|
.with_stderr(
|
|
|
|
"[ERROR] Only `-l` and `-L` flags are allowed in target config \
|
|
|
|
`target.[..].rustc-flags` (in [..]foo/.cargo/config): `foo`",
|
|
|
|
)
|
2019-11-24 17:43:59 +00:00
|
|
|
.run();
|
|
|
|
|
|
|
|
p.change_file(
|
|
|
|
".cargo/config",
|
|
|
|
&format!(
|
|
|
|
"[target.{}.somelib]
|
|
|
|
warning = \"foo\"
|
|
|
|
",
|
|
|
|
rustc_host(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
p.cargo("check")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr("[ERROR] `warning` is not supported in build script overrides")
|
|
|
|
.run();
|
|
|
|
}
|
2019-12-28 20:51:56 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn redefined_sources() {
|
|
|
|
// Cannot define a source multiple times.
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
|
|
|
[source.foo]
|
|
|
|
registry = "https://github.com/rust-lang/crates.io-index"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] source `foo` defines source registry `https://github.com/rust-lang/crates.io-index`, \
|
|
|
|
but that source is already defined by `crates-io`
|
|
|
|
note: Sources are not allowed to be defined multiple times.
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
p.change_file(
|
|
|
|
".cargo/config",
|
|
|
|
r#"
|
|
|
|
[source.one]
|
|
|
|
directory = "index"
|
|
|
|
|
|
|
|
[source.two]
|
|
|
|
directory = "index"
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Name is `[..]` because we can't guarantee the order.
|
|
|
|
p.cargo("check")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] source `[..]` defines source dir [..]/foo/index, \
|
|
|
|
but that source is already defined by `[..]`
|
|
|
|
note: Sources are not allowed to be defined multiple times.
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|