diff --git a/libs/toml-rs b/libs/toml-rs index a0f1ea65f..3a7ec7f4c 160000 --- a/libs/toml-rs +++ b/libs/toml-rs @@ -1 +1 @@ -Subproject commit a0f1ea65fc80379f0c6c095d92fad840004aaa56 +Subproject commit 3a7ec7f4c4716d2967aedab2ef3d051c9cfc2041 diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index a8e71d3e3..ead9fde13 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -309,7 +309,7 @@ fn extract_config(mut file: io::fs::File, key: &str) -> CargoResult let mut toml = try!(cargo_toml::parse(contents.as_slice(), file.path().filename_display() .to_string().as_slice())); - let val = try!(toml.pop_equiv(&key).require(|| internal(""))); + let val = try!(toml.pop(&key.to_string()).require(|| internal(""))); ConfigValue::from_toml(file.path(), val) } diff --git a/tests/support/mod.rs b/tests/support/mod.rs index fd99e08d8..302467362 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -401,10 +401,6 @@ impl Tap for T { } } -pub fn escape_path(p: &Path) -> String { - p.display().to_string().as_slice().replace("\\", "\\\\") -} - pub fn basic_bin_manifest(name: &str) -> String { format!(r#" [package] diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index c722957ae..db114ac84 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -3,7 +3,7 @@ use std::os; use std::path; use std::str; -use support::{ResultTest, project, execs, main_file, escape_path, basic_bin_manifest}; +use support::{ResultTest, project, execs, main_file, basic_bin_manifest}; use support::{COMPILING, RUNNING}; use hamcrest::{assert_that, existing_file}; use cargo; @@ -146,8 +146,8 @@ test!(cargo_compile_with_warnings_in_a_dep_package { p = p .file(".cargo/config", format!(r#" - paths = ["{}"] - "#, escape_path(&bar)).as_slice()) + paths = ['{}'] + "#, bar.display()).as_slice()) .file("Cargo.toml", r#" [project] @@ -209,8 +209,8 @@ test!(cargo_compile_with_nested_deps_inferred { p = p .file(".cargo/config", format!(r#" - paths = ["{}", "{}"] - "#, escape_path(&bar), escape_path(&baz)).as_slice()) + paths = ['{}', '{}'] + "#, bar.display(), baz.display()).as_slice()) .file("Cargo.toml", r#" [project] @@ -277,8 +277,8 @@ test!(cargo_compile_with_nested_deps_correct_bin { p = p .file(".cargo/config", format!(r#" - paths = ["{}", "{}"] - "#, escape_path(&bar), escape_path(&baz)).as_slice()) + paths = ['{}', '{}'] + "#, bar.display(), baz.display()).as_slice()) .file("Cargo.toml", r#" [project] @@ -345,8 +345,8 @@ test!(cargo_compile_with_nested_deps_shorthand { p = p .file(".cargo/config", format!(r#" - paths = ["{}", "{}"] - "#, escape_path(&bar), escape_path(&baz)).as_slice()) + paths = ['{}', '{}'] + "#, bar.display(), baz.display()).as_slice()) .file("Cargo.toml", r#" [project] @@ -421,8 +421,8 @@ test!(cargo_compile_with_nested_deps_longhand { p = p .file(".cargo/config", format!(r#" - paths = ["{}", "{}"] - "#, escape_path(&bar), escape_path(&baz)).as_slice()) + paths = ['{}', '{}'] + "#, bar.display(), baz.display()).as_slice()) .file("Cargo.toml", r#" [project] @@ -517,10 +517,10 @@ test!(custom_build { name = "foo" version = "0.5.0" authors = ["wycats@example.com"] - build = "{}" + build = '{}' [[bin]] name = "foo" - "#, escape_path(&build.bin("foo")))) + "#, build.bin("foo").display())) .file("src/foo.rs", r#" fn main() {} "#); @@ -581,10 +581,10 @@ test!(custom_multiple_build { name = "foo" version = "0.5.0" authors = ["wycats@example.com"] - build = [ "{} hello world", "{} cargo" ] + build = [ '{} hello world', '{} cargo' ] [[bin]] name = "foo" - "#, escape_path(&build1.bin("foo")), escape_path(&build2.bin("bar")))) + "#, build1.bin("foo").display(), build2.bin("bar").display())) .file("src/foo.rs", r#" fn main() {} "#); @@ -622,11 +622,11 @@ test!(custom_build_failure { name = "foo" version = "0.5.0" authors = ["wycats@example.com"] - build = "{}" + build = '{}' [[bin]] name = "foo" - "#, escape_path(&build.bin("foo")))) + "#, build.bin("foo").display())) .file("src/foo.rs", r#" fn main() {} "#); @@ -683,11 +683,11 @@ test!(custom_second_build_failure { name = "foo" version = "0.5.0" authors = ["wycats@example.com"] - build = [ "{}", "{}" ] + build = [ '{}', '{}' ] [[bin]] name = "foo" - "#, escape_path(&build1.bin("foo")), escape_path(&build2.bin("bar")))) + "#, build1.bin("foo").display(), build2.bin("bar").display())) .file("src/foo.rs", r#" fn main() {} "#); @@ -717,12 +717,12 @@ test!(custom_build_env_vars { .file("src/foo.rs", format!(r#" use std::os; fn main() {{ - assert_eq!(os::getenv("OUT_DIR").unwrap(), "{}".to_string()); - assert_eq!(os::getenv("DEPS_DIR").unwrap(), "{}".to_string()); + assert_eq!(os::getenv("OUT_DIR").unwrap(), r"{}".to_string()); + assert_eq!(os::getenv("DEPS_DIR").unwrap(), r"{}".to_string()); }} "#, - escape_path(&p.root().join("target")), - escape_path(&p.root().join("target").join("deps")))); + p.root().join("target").display(), + p.root().join("target").join("deps").display())); assert_that(build.cargo_process("cargo-build"), execs().with_status(0)); @@ -733,11 +733,11 @@ test!(custom_build_env_vars { name = "foo" version = "0.5.0" authors = ["wycats@example.com"] - build = "{}" + build = '{}' [[bin]] name = "foo" - "#, escape_path(&build.bin("foo")))) + "#, build.bin("foo").display())) .file("src/foo.rs", r#" fn main() {} "#); @@ -762,19 +762,19 @@ test!(custom_build_in_dependency { .file("src/foo.rs", format!(r#" use std::os; fn main() {{ - assert_eq!(os::getenv("OUT_DIR").unwrap(), "{}".to_string()); - assert_eq!(os::getenv("DEPS_DIR").unwrap(), "{}".to_string()); + assert_eq!(os::getenv("OUT_DIR").unwrap(), r"{}".to_string()); + assert_eq!(os::getenv("DEPS_DIR").unwrap(), r"{}".to_string()); }} "#, - escape_path(&p.root().join("target/deps")), - escape_path(&p.root().join("target/deps")))); + p.root().join("target/deps").display(), + p.root().join("target/deps").display())); assert_that(build.cargo_process("cargo-build"), execs().with_status(0)); p = p .file(".cargo/config", format!(r#" - paths = ["{}"] - "#, escape_path(&bar)).as_slice()) + paths = ['{}'] + "#, bar.display()).as_slice()) .file("Cargo.toml", r#" [project] @@ -797,8 +797,8 @@ test!(custom_build_in_dependency { name = "bar" version = "0.5.0" authors = ["wycats@example.com"] - build = "{}" - "#, escape_path(&build.bin("foo")))) + build = '{}' + "#, build.bin("foo").display())) .file("bar/src/lib.rs", r#" pub fn bar() {} "#); diff --git a/tests/test_cargo_compile_git_deps.rs b/tests/test_cargo_compile_git_deps.rs index 01a39aa08..b0ae8c267 100644 --- a/tests/test_cargo_compile_git_deps.rs +++ b/tests/test_cargo_compile_git_deps.rs @@ -1,7 +1,7 @@ use std::io::File; use support::{ProjectBuilder, ResultTest, project, execs, main_file, paths}; -use support::{escape_path, cargo_dir}; +use support::{cargo_dir}; use support::{COMPILING, FRESH, UPDATING}; use hamcrest::{assert_that,existing_file}; use cargo; @@ -71,12 +71,12 @@ test!(cargo_compile_simple_git_dep { [dependencies.dep1] - git = "file:{}" + git = 'file:{}' [[bin]] name = "foo" - "#, escape_path(&git_project.root()))) + "#, git_project.root().display())) .file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"])); let root = project.root(); @@ -134,13 +134,13 @@ test!(cargo_compile_git_dep_branch { [dependencies.dep1] - git = "file:{}" + git = 'file:{}' branch = "branchy" [[bin]] name = "foo" - "#, escape_path(&git_project.root()))) + "#, git_project.root().display())) .file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"])); let root = project.root(); @@ -199,13 +199,13 @@ test!(cargo_compile_git_dep_tag { [dependencies.dep1] - git = "file:{}" + git = 'file:{}' tag = "v0.1.0" [[bin]] name = "foo" - "#, escape_path(&git_project.root()))) + "#, git_project.root().display())) .file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"])); let root = project.root(); @@ -283,12 +283,12 @@ test!(cargo_compile_with_nested_paths { [dependencies.dep1] version = "0.5.0" - git = "file:{}" + git = 'file:{}' [[bin]] name = "parent" - "#, escape_path(&git_project.root()))) + "#, git_project.root().display())) .file("src/parent.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"]).as_slice()); @@ -351,17 +351,17 @@ test!(cargo_compile_with_meta_package { [dependencies.dep1] version = "0.5.0" - git = "file:{}" + git = 'file:{}' [dependencies.dep2] version = "0.5.0" - git = "file:{}" + git = 'file:{}' [[bin]] name = "parent" - "#, escape_path(&git_project.root()), escape_path(&git_project.root()))) + "#, git_project.root().display(), git_project.root().display())) .file("src/parent.rs", main_file(r#""{} {}", dep1::hello(), dep2::hello()"#, ["dep1", "dep2"]).as_slice()); @@ -438,12 +438,12 @@ test!(two_revs_same_deps { authors = [] [dependencies.bar] - git = "file:{}" + git = 'file:{}' rev = "{}" [dependencies.baz] path = "../baz" - "#, escape_path(&bar.root()), rev1.as_slice().trim()).as_slice()) + "#, bar.root().display(), rev1.as_slice().trim()).as_slice()) .file("src/main.rs", r#" extern crate bar; extern crate baz; @@ -462,9 +462,9 @@ test!(two_revs_same_deps { authors = [] [dependencies.bar] - git = "file:{}" + git = 'file:{}' rev = "{}" - "#, escape_path(&bar.root()), rev2.as_slice().trim()).as_slice()) + "#, bar.root().display(), rev2.as_slice().trim()).as_slice()) .file("src/lib.rs", r#" extern crate bar; pub fn baz() -> int { bar::bar() } @@ -508,12 +508,12 @@ test!(recompilation { [dependencies.bar] version = "0.5.0" - git = "file:{}" + git = 'file:{}' [[bin]] name = "foo" - "#, escape_path(&git_project.root()))) + "#, git_project.root().display())) .file("src/foo.rs", main_file(r#""{}", bar::bar()"#, ["bar"]).as_slice()); diff --git a/tests/test_cargo_compile_path_deps.rs b/tests/test_cargo_compile_path_deps.rs index 3b031301c..d721ec644 100644 --- a/tests/test_cargo_compile_path_deps.rs +++ b/tests/test_cargo_compile_path_deps.rs @@ -1,7 +1,7 @@ use std::io::File; use std::io::timer; -use support::{ResultTest, project, execs, main_file, escape_path, cargo_dir}; +use support::{ResultTest, project, execs, main_file, cargo_dir}; use support::{COMPILING, FRESH}; use hamcrest::{assert_that, existing_file}; use cargo; @@ -208,8 +208,8 @@ test!(no_rebuild_dependency { let bar = p.root().join("bar"); p = p .file(".cargo/config", format!(r#" - paths = ["{}"] - "#, escape_path(&bar)).as_slice()) + paths = ['{}'] + "#, bar.display()).as_slice()) .file("Cargo.toml", r#" [project] @@ -263,8 +263,8 @@ test!(deep_dependencies_trigger_rebuild { let baz = p.root().join("baz"); p = p .file(".cargo/config", format!(r#" - paths = ["{}", "{}"] - "#, escape_path(&bar), escape_path(&baz)).as_slice()) + paths = ['{}', '{}'] + "#, bar.display(), baz.display()).as_slice()) .file("Cargo.toml", r#" [project] @@ -361,8 +361,8 @@ test!(no_rebuild_two_deps { let baz = p.root().join("baz"); p = p .file(".cargo/config", format!(r#" - paths = ["{}", "{}"] - "#, escape_path(&bar), escape_path(&baz)).as_slice()) + paths = ['{}', '{}'] + "#, bar.display(), baz.display()).as_slice()) .file("Cargo.toml", r#" [project]