2016-05-10 23:52:02 +00:00
|
|
|
use support::{project, execs};
|
2016-01-11 16:08:20 +00:00
|
|
|
use support::registry::Package;
|
2015-01-14 17:58:43 +00:00
|
|
|
use hamcrest::assert_that;
|
|
|
|
|
|
|
|
fn setup() {}
|
|
|
|
|
|
|
|
test!(bad1 {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(".cargo/config", r#"
|
2015-01-19 05:02:25 +00:00
|
|
|
[target]
|
|
|
|
nonexistent-target = "foo"
|
2015-01-14 17:58:43 +00:00
|
|
|
"#);
|
2015-01-19 05:02:25 +00:00
|
|
|
assert_that(foo.cargo_process("build").arg("-v")
|
|
|
|
.arg("--target=nonexistent-target"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] expected table for configuration key `target.nonexistent-target`, \
|
2016-02-27 18:53:30 +00:00
|
|
|
but found string in [..]config
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2015-01-14 17:58:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test!(bad2 {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(".cargo/config", r#"
|
|
|
|
[http]
|
2015-01-14 18:11:08 +00:00
|
|
|
proxy = 3.0
|
2015-01-14 17:58:43 +00:00
|
|
|
"#);
|
|
|
|
assert_that(foo.cargo_process("publish").arg("-v"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] Couldn't 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`
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2015-01-14 17:58:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test!(bad3 {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(".cargo/config", r#"
|
|
|
|
[http]
|
|
|
|
proxy = true
|
|
|
|
"#);
|
|
|
|
assert_that(foo.cargo_process("publish").arg("-v"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] invalid configuration for key `http.proxy`
|
2015-01-14 17:58:43 +00:00
|
|
|
expected a string, but found a boolean in [..]config
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2015-01-14 17:58:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test!(bad4 {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file(".cargo/config", r#"
|
|
|
|
[cargo-new]
|
|
|
|
name = false
|
|
|
|
"#);
|
|
|
|
assert_that(foo.cargo_process("new").arg("-v").arg("foo"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] Failed to create project `foo` at `[..]`
|
2015-01-14 17:58:43 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
invalid configuration for key `cargo-new.name`
|
|
|
|
expected a string, but found a boolean in [..]config
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2015-01-14 17:58:43 +00:00
|
|
|
});
|
2015-01-15 08:20:56 +00:00
|
|
|
|
2015-01-19 05:02:25 +00:00
|
|
|
test!(bad5 {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file(".cargo/config", r#"
|
|
|
|
foo = ""
|
|
|
|
"#)
|
|
|
|
.file("foo/.cargo/config", r#"
|
|
|
|
foo = 2
|
|
|
|
"#);
|
|
|
|
foo.build();
|
2015-02-27 01:04:25 +00:00
|
|
|
assert_that(foo.cargo("new")
|
|
|
|
.arg("-v").arg("foo").cwd(&foo.root().join("foo")),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] Couldn't load Cargo configuration
|
2015-01-19 05:02:25 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to merge key `foo` between files:
|
|
|
|
file 1: [..]foo[..]foo[..]config
|
|
|
|
file 2: [..]foo[..]config
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
expected integer, but found string
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2015-01-19 05:02:25 +00:00
|
|
|
});
|
2015-01-15 08:20:56 +00:00
|
|
|
|
|
|
|
test!(bad_cargo_config_jobs {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(".cargo/config", r#"
|
|
|
|
[build]
|
|
|
|
jobs = -1
|
|
|
|
"#);
|
|
|
|
assert_that(foo.cargo_process("build").arg("-v"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] build.jobs must be positive, but found -1 in [..]
|
|
|
|
"));
|
2015-01-15 08:20:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test!(default_cargo_config_jobs {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(".cargo/config", r#"
|
|
|
|
[build]
|
|
|
|
jobs = 1
|
|
|
|
"#);
|
|
|
|
assert_that(foo.cargo_process("build").arg("-v"),
|
|
|
|
execs().with_status(0));
|
|
|
|
});
|
|
|
|
|
|
|
|
test!(good_cargo_config_jobs {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(".cargo/config", r#"
|
|
|
|
[build]
|
|
|
|
jobs = 4
|
|
|
|
"#);
|
|
|
|
assert_that(foo.cargo_process("build").arg("-v"),
|
|
|
|
execs().with_status(0));
|
|
|
|
});
|
2015-01-15 19:12:13 +00:00
|
|
|
|
|
|
|
test!(invalid_global_config {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
|
|
|
"#)
|
|
|
|
.file(".cargo/config", "4")
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(foo.cargo_process("build").arg("-v"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] Couldn't load Cargo configuration
|
2015-01-15 19:12:13 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
could not parse TOML configuration in `[..]config`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
could not parse input as TOML
|
2015-10-07 17:37:56 +00:00
|
|
|
[..]config:1:2 expected `=`, but found eof
|
2015-01-15 19:12:13 +00:00
|
|
|
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2015-01-15 19:12:13 +00:00
|
|
|
});
|
2015-02-04 07:27:06 +00:00
|
|
|
|
|
|
|
test!(bad_cargo_lock {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("Cargo.lock", "")
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(foo.cargo_process("build").arg("-v"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] failed to parse lock file at: [..]Cargo.lock
|
2015-02-04 07:27:06 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
expected a section for the key `root`
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2015-02-04 07:27:06 +00:00
|
|
|
});
|
2015-08-13 16:25:24 +00:00
|
|
|
|
|
|
|
test!(bad_git_dependency {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = { git = "file:.." }
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(foo.cargo_process("build").arg("-v"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] Unable to update file:///
|
2015-08-13 16:25:24 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to clone into: [..]
|
|
|
|
|
|
|
|
Caused by:
|
2015-11-19 17:13:21 +00:00
|
|
|
[[..]] 'file:///' is not a valid local file URI
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2015-08-13 16:25:24 +00:00
|
|
|
});
|
2015-08-15 19:49:09 +00:00
|
|
|
|
|
|
|
test!(bad_crate_type {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[lib]
|
|
|
|
crate-type = ["bad_type", "rlib"]
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(foo.cargo_process("build").arg("-v"),
|
|
|
|
execs().with_status(0).with_stderr("\
|
|
|
|
warning: crate-type \"bad_type\" was not one of lib|rlib|dylib|staticlib
|
|
|
|
"));
|
|
|
|
});
|
2015-10-07 17:37:56 +00:00
|
|
|
|
|
|
|
test!(malformed_override {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[target.x86_64-apple-darwin.freetype]
|
|
|
|
native = {
|
|
|
|
foo: "bar"
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(foo.cargo_process("build"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] failed to parse manifest at `[..]`
|
2015-10-07 17:37:56 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
could not parse input as TOML
|
|
|
|
Cargo.toml:[..]
|
|
|
|
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2015-10-07 17:37:56 +00:00
|
|
|
});
|
2015-11-23 00:47:30 +00:00
|
|
|
|
|
|
|
test!(duplicate_binary_names {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "qqq"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = ["A <a@a.a>"]
|
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
name = "e"
|
|
|
|
path = "a.rs"
|
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
name = "e"
|
|
|
|
path = "b.rs"
|
|
|
|
"#)
|
|
|
|
.file("a.rs", r#"fn main() -> () {}"#)
|
|
|
|
.file("b.rs", r#"fn main() -> () {}"#);
|
|
|
|
|
|
|
|
assert_that(foo.cargo_process("build"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[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
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2015-11-23 00:47:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test!(duplicate_example_names {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "qqq"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = ["A <a@a.a>"]
|
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "ex"
|
|
|
|
path = "examples/ex.rs"
|
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "ex"
|
|
|
|
path = "examples/ex2.rs"
|
|
|
|
"#)
|
|
|
|
.file("examples/ex.rs", r#"fn main () -> () {}"#)
|
|
|
|
.file("examples/ex2.rs", r#"fn main () -> () {}"#);
|
|
|
|
|
|
|
|
assert_that(foo.cargo_process("build").arg("--example").arg("ex"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] failed to parse manifest at `[..]`
|
2015-11-23 00:47:30 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
found duplicate example name ex, but all binary targets must have a unique name
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2015-11-23 00:47:30 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test!(duplicate_bench_names {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "qqq"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = ["A <a@a.a>"]
|
|
|
|
|
|
|
|
[[bench]]
|
|
|
|
name = "ex"
|
|
|
|
path = "benches/ex.rs"
|
|
|
|
|
|
|
|
[[bench]]
|
|
|
|
name = "ex"
|
|
|
|
path = "benches/ex2.rs"
|
|
|
|
"#)
|
|
|
|
.file("benches/ex.rs", r#"fn main () {}"#)
|
|
|
|
.file("benches/ex2.rs", r#"fn main () {}"#);
|
|
|
|
|
|
|
|
assert_that(foo.cargo_process("bench"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] failed to parse manifest at `[..]`
|
2015-11-23 00:47:30 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
found duplicate bench name ex, but all binary targets must have a unique name
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2016-03-17 20:04:33 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test!(duplicate_deps {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("shim-bar/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("shim-bar/src/lib.rs", r#"
|
|
|
|
pub fn a() {}
|
|
|
|
"#)
|
|
|
|
.file("linux-bar/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("linux-bar/src/lib.rs", r#"
|
|
|
|
pub fn a() {}
|
|
|
|
"#)
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "qqq"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { path = "shim-bar" }
|
|
|
|
|
|
|
|
[target.x86_64-unknown-linux-gnu.dependencies]
|
|
|
|
bar = { path = "linux-bar" }
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", r#"fn main () {}"#);
|
|
|
|
|
|
|
|
assert_that(foo.cargo_process("build"),
|
2016-05-10 23:52:02 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
[ERROR] failed to parse manifest at `[..]`
|
2016-03-17 20:04:33 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
found duplicate dependency name bar, but all dependencies must have a unique name
|
2016-05-10 23:52:02 +00:00
|
|
|
"));
|
2015-11-23 00:47:30 +00:00
|
|
|
});
|
2015-12-19 00:33:17 +00:00
|
|
|
|
|
|
|
test!(unused_keys {
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[target.foo]
|
|
|
|
bar = "3"
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(foo.cargo_process("build"),
|
|
|
|
execs().with_status(0).with_stderr("\
|
2016-03-13 22:24:55 +00:00
|
|
|
warning: unused manifest key: target.foo.bar
|
2015-12-19 00:33:17 +00:00
|
|
|
"));
|
|
|
|
});
|
2016-01-11 16:08:20 +00:00
|
|
|
|
|
|
|
test!(empty_dependencies {
|
|
|
|
let p = project("empty_deps")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "empty_deps"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = {}
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
|
|
|
|
Package::new("foo", "0.0.1").publish();
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(0).with_stderr_contains("\
|
|
|
|
warning: dependency (foo) specified without providing a local path, Git repository, or version \
|
|
|
|
to use. This will be considered an error in future versions
|
|
|
|
"));
|
|
|
|
});
|