From: Carl Lerche Date: Tue, 27 May 2014 23:14:34 +0000 (-0700) Subject: Track rust master X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~1047 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7e6433fedaf7afc0e76c9982352aba08abd06fbf;p=cargo.git Track rust master --- diff --git a/libs/hamcrest-rust b/libs/hamcrest-rust index f410b93c7..e9d78bcff 160000 --- a/libs/hamcrest-rust +++ b/libs/hamcrest-rust @@ -1 +1 @@ -Subproject commit f410b93c78c4e2a71c7d82b9e49a3a3a13669b9a +Subproject commit e9d78bcff974668475752d553f3813df2cc018b2 diff --git a/tests/support.rs b/tests/support.rs index 338564da5..9dee66e6e 100644 --- a/tests/support.rs +++ b/tests/support.rs @@ -22,7 +22,7 @@ static CARGO_INTEGRATION_TEST_DIR : &'static str = "cargo-integration-tests"; #[deriving(Eq,Clone)] struct FileBuilder { path: Path, - body: ~str + body: String } impl FileBuilder { @@ -30,7 +30,7 @@ impl FileBuilder { FileBuilder { path: path, body: body.to_owned() } } - fn mk(&self) -> Result<(), ~str> { + fn mk(&self) -> Result<(), String> { try!(mkdir_recursive(&self.dirname())); let mut file = try!( @@ -48,7 +48,7 @@ impl FileBuilder { #[deriving(Eq,Clone)] struct ProjectBuilder { - name: ~str, + name: String, root: Path, files: Vec } @@ -87,7 +87,7 @@ impl ProjectBuilder { } } - pub fn build_with_result(&self) -> Result<(), ~str> { + pub fn build_with_result(&self) -> Result<(), String> { // First, clean the directory if it already exists try!(self.rm_root()); @@ -101,7 +101,7 @@ impl ProjectBuilder { Ok(()) } - fn rm_root(&self) -> Result<(), ~str> { + fn rm_root(&self) -> Result<(), String> { if self.root.exists() { rmdir_recursive(&self.root) } @@ -118,22 +118,22 @@ pub fn project(name: &str) -> ProjectBuilder { // === Helpers === -pub fn mkdir_recursive(path: &Path) -> Result<(), ~str> { +pub fn mkdir_recursive(path: &Path) -> Result<(), String> { fs::mkdir_recursive(path, io::UserDir) .with_err_msg(format!("could not create directory; path={}", path.display())) } -pub fn rmdir_recursive(path: &Path) -> Result<(), ~str> { +pub fn rmdir_recursive(path: &Path) -> Result<(), String> { fs::rmdir_recursive(path) .with_err_msg(format!("could not rm directory; path={}", path.display())) } trait ErrMsg { - fn with_err_msg(self, val: ~str) -> Result; + fn with_err_msg(self, val: String) -> Result; } impl ErrMsg for Result { - fn with_err_msg(self, val: ~str) -> Result { + fn with_err_msg(self, val: String) -> Result { match self { Ok(val) => Ok(val), Err(err) => Err(format!("{}; original={}", val, err)) @@ -156,9 +156,9 @@ pub fn cargo_dir() -> Path { #[deriving(Clone,Eq)] struct Execs { - expect_stdout: Option<~str>, - expect_stdin: Option<~str>, - expect_stderr: Option<~str>, + expect_stdout: Option, + expect_stdin: Option, + expect_stderr: Option, expect_exit_code: Option } @@ -204,7 +204,7 @@ impl Execs { self.match_std(&self.expect_stderr, actual, "stderr") } - fn match_std(&self, expected: &Option<~str>, actual: &Vec, description: &str) -> ham::MatchResult { + fn match_std(&self, expected: &Option, actual: &Vec, description: &str) -> ham::MatchResult { match expected.as_ref().map(|s| s.as_slice()) { None => ham::success(), Some(out) => { @@ -220,7 +220,7 @@ impl Execs { } impl ham::SelfDescribing for Execs { - fn describe(&self) -> ~str { + fn describe(&self) -> String { "execs".to_owned() } } diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index 15b29c284..7b984425c 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -6,7 +6,7 @@ use cargo::util::process; fn setup() { } -fn basic_bin_manifest(name: &str) -> ~str { +fn basic_bin_manifest(name: &str) -> String { format!(r#" [project] @@ -22,8 +22,8 @@ fn basic_bin_manifest(name: &str) -> ~str { test!(cargo_compile { let p = project("foo") - .file("Cargo.toml", basic_bin_manifest("foo")) - .file("src/foo.rs", main_file(r#""i am foo""#, [])); + .file("Cargo.toml", basic_bin_manifest("foo").as_slice()) + .file("src/foo.rs", main_file(r#""i am foo""#, []).as_slice()); assert_that(p.cargo_process("cargo-compile"), execs()); assert_that(&p.root().join("target/foo"), existing_file()); @@ -56,7 +56,7 @@ test!(cargo_compile_without_manifest { test!(cargo_compile_with_invalid_code { let p = project("foo") - .file("Cargo.toml", basic_bin_manifest("foo")) + .file("Cargo.toml", basic_bin_manifest("foo").as_slice()) .file("src/foo.rs", "invalid rust code!"); let target = p.root().join("target"); @@ -64,12 +64,12 @@ test!(cargo_compile_with_invalid_code { assert_that(p.cargo_process("cargo-compile"), execs() .with_status(101) - .with_stderr(format!("src/foo.rs:1:1: 1:8 error: expected item but found `invalid`\nsrc/foo.rs:1 invalid rust code!\n ^~~~~~~\nfailed to execute: `rustc src/foo.rs --crate-type bin --out-dir {} -L {}`", target.display(), target.display()))); + .with_stderr(format!("src/foo.rs:1:1: 1:8 error: expected item but found `invalid`\nsrc/foo.rs:1 invalid rust code!\n ^~~~~~~\nfailed to execute: `rustc src/foo.rs --crate-type bin --out-dir {} -L {}`", target.display(), target.display()).as_slice())); }) test!(cargo_compile_with_warnings_in_the_root_package { let p = project("foo") - .file("Cargo.toml", basic_bin_manifest("foo")) + .file("Cargo.toml", basic_bin_manifest("foo").as_slice()) .file("src/foo.rs", "fn main() {} fn dead() {}"); assert_that(p.cargo_process("cargo-compile"), @@ -84,7 +84,7 @@ test!(cargo_compile_with_warnings_in_a_dep_package { p = p .file(".cargo/config", format!(r#" paths = ["{}"] - "#, bar.display())) + "#, bar.display()).as_slice()) .file("Cargo.toml", r#" [project] @@ -100,7 +100,7 @@ test!(cargo_compile_with_warnings_in_a_dep_package { name = "foo" "#) - .file("src/foo.rs", main_file(r#""{}", bar::gimme()"#, ["bar"])) + .file("src/foo.rs", main_file(r#""{}", bar::gimme()"#, ["bar"]).as_slice()) .file("bar/Cargo.toml", r#" [project] @@ -113,7 +113,7 @@ test!(cargo_compile_with_warnings_in_a_dep_package { name = "bar" "#) .file("bar/src/bar.rs", r#" - pub fn gimme() -> ~str { + pub fn gimme() -> String { "test passed".to_owned() } @@ -140,7 +140,7 @@ test!(cargo_compile_with_nested_deps { p = p .file(".cargo/config", format!(r#" paths = ["{}", "{}"] - "#, bar.display(), baz.display())) + "#, bar.display(), baz.display()).as_slice()) .file("Cargo.toml", r#" [project] @@ -156,7 +156,7 @@ test!(cargo_compile_with_nested_deps { name = "foo" "#) - .file("src/foo.rs", main_file(r#""{}", bar::gimme()"#, ["bar"])) + .file("src/foo.rs", main_file(r#""{}", bar::gimme()"#, ["bar"]).as_slice()) .file("bar/Cargo.toml", r#" [project] @@ -175,7 +175,7 @@ test!(cargo_compile_with_nested_deps { .file("bar/src/bar.rs", r#" extern crate baz; - pub fn gimme() -> ~str { + pub fn gimme() -> String { baz::gimme() } "#) @@ -191,7 +191,7 @@ test!(cargo_compile_with_nested_deps { name = "baz" "#) .file("baz/src/baz.rs", r#" - pub fn gimme() -> ~str { + pub fn gimme() -> String { "test passed".to_owned() } "#); @@ -207,11 +207,11 @@ test!(cargo_compile_with_nested_deps { execs().with_stdout("test passed\n")); }) -fn main_file(println: &str, deps: &[&str]) -> ~str { - let mut buf = StrBuf::new(); +fn main_file(println: &str, deps: &[&str]) -> String { + let mut buf = String::new(); for dep in deps.iter() { - buf.push_str(format!("extern crate {};\n", dep)); + buf.push_str(format!("extern crate {};\n", dep).as_slice()); } buf.push_str("fn main() { println!(");