mirror of
https://github.com/rust-lang/cargo
synced 2024-11-05 18:50:39 +00:00
parent
99c8768f80
commit
670fc47d71
2 changed files with 28 additions and 8 deletions
|
@ -255,7 +255,7 @@ pub fn all_configs(pwd: Path) -> CargoResult<HashMap<string::String, ConfigValue
|
|||
let value = try!(ConfigValue::from_toml(&path, toml::Table(table)));
|
||||
try!(cfg.merge(value));
|
||||
Ok(())
|
||||
}).map_err(|_| human("Couldn't load Cargo configuration")));
|
||||
}).chain_error(|| human("Couldn't load Cargo configuration")));
|
||||
|
||||
|
||||
match cfg {
|
||||
|
@ -288,20 +288,14 @@ fn find_in_tree<T>(pwd: &Path,
|
|||
fn walk_tree(pwd: &Path,
|
||||
walk: |File| -> CargoResult<()>) -> CargoResult<()> {
|
||||
let mut current = pwd.clone();
|
||||
let mut err = false;
|
||||
|
||||
loop {
|
||||
let possible = current.join(".cargo").join("config");
|
||||
if possible.exists() {
|
||||
let file = try!(File::open(&possible));
|
||||
|
||||
match walk(file) {
|
||||
Err(_) => err = false,
|
||||
_ => ()
|
||||
}
|
||||
try!(walk(file));
|
||||
}
|
||||
|
||||
if err { return Err(internal("")); }
|
||||
if !current.pop() { break; }
|
||||
}
|
||||
|
||||
|
|
|
@ -1684,3 +1684,29 @@ test!(ignore_bad_directories {
|
|||
assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
|
||||
execs().with_status(0));
|
||||
})
|
||||
|
||||
test!(bad_cargo_config {
|
||||
let foo = project("foo")
|
||||
.file("Cargo.toml", r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.0"
|
||||
authors = []
|
||||
"#)
|
||||
.file("src/lib.rs", "")
|
||||
.file(".cargo/config", r#"
|
||||
this is not valid toml
|
||||
"#);
|
||||
assert_that(foo.cargo_process("build").arg("-v"),
|
||||
execs().with_status(101).with_stderr("\
|
||||
Couldn't load Cargo configuration
|
||||
|
||||
Caused by:
|
||||
could not parse Toml manifest; path=[..]
|
||||
|
||||
Caused by:
|
||||
could not parse input TOML
|
||||
[..].cargo[..]config:2:20-2:21 expected `=`, but found `i`
|
||||
|
||||
"));
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue