Update toml-rs

TOML recently grew multiline string literals as well as literal strings with no
escaping, which can be used instead of the hokey escape_path() function.
This commit is contained in:
Alex Crichton 2014-07-16 08:08:55 -07:00
parent 2726d1b98d
commit 3608fd4892
6 changed files with 60 additions and 64 deletions

@ -1 +1 @@
Subproject commit a0f1ea65fc80379f0c6c095d92fad840004aaa56
Subproject commit 3a7ec7f4c4716d2967aedab2ef3d051c9cfc2041

View File

@ -309,7 +309,7 @@ fn extract_config(mut file: io::fs::File, key: &str) -> CargoResult<ConfigValue>
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)
}

View File

@ -401,10 +401,6 @@ impl<T> 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]

View File

@ -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() {}
"#);

View File

@ -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());

View File

@ -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]