Track rust master
authorCarl Lerche <me@carllerche.com>
Tue, 27 May 2014 23:14:34 +0000 (16:14 -0700)
committerCarl Lerche <me@carllerche.com>
Tue, 27 May 2014 23:14:34 +0000 (16:14 -0700)
libs/hamcrest-rust
tests/support.rs
tests/test_cargo_compile.rs

index f410b93c78c4e2a71c7d82b9e49a3a3a13669b9a..e9d78bcff974668475752d553f3813df2cc018b2 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f410b93c78c4e2a71c7d82b9e49a3a3a13669b9a
+Subproject commit e9d78bcff974668475752d553f3813df2cc018b2
index 338564da598127afc02aaaed75c296689ad84b0c..9dee66e6e94338099e4accae7ca70bc6448bb395 100644 (file)
@@ -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<FileBuilder>
 }
@@ -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<T> {
-    fn with_err_msg(self, val: ~str) -> Result<T, ~str>;
+    fn with_err_msg(self, val: String) -> Result<T, String>;
 }
 
 impl<T, E: Show> ErrMsg<T> for Result<T, E> {
-    fn with_err_msg(self, val: ~str) -> Result<T, ~str> {
+    fn with_err_msg(self, val: String) -> Result<T, String> {
         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<String>,
+    expect_stdin: Option<String>,
+    expect_stderr: Option<String>,
     expect_exit_code: Option<int>
 }
 
@@ -204,7 +204,7 @@ impl Execs {
       self.match_std(&self.expect_stderr, actual, "stderr")
   }
 
-  fn match_std(&self, expected: &Option<~str>, actual: &Vec<u8>, description: &str) -> ham::MatchResult {
+  fn match_std(&self, expected: &Option<String>, actual: &Vec<u8>, 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()
   }
 }
index 15b29c284bb06d63bcf54fffa30959c56cc6c405..7b984425c454e6d8165ca91b68c9a65c911d7076 100644 (file)
@@ -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!(");