Track master for tests
authorYehuda Katz + Carl Lerche <engineering@tilde.io>
Mon, 9 Jun 2014 20:08:09 +0000 (13:08 -0700)
committerTim Carey-Smith <tim@spork.in>
Mon, 9 Jun 2014 20:08:09 +0000 (13:08 -0700)
libs/hamcrest-rust
src/bin/cargo-verify-project.rs
src/bin/cargo.rs
src/cargo/lib.rs
tests/support.rs
tests/test_cargo_compile.rs

index 822fc16016ccd5d24ba460d141e8f2d17db883a0..a3844d6e0c6b84934078b7ee0e6e702c59cc5242 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 822fc16016ccd5d24ba460d141e8f2d17db883a0
+Subproject commit a3844d6e0c6b84934078b7ee0e6e702c59cc5242
index 92d23568a025ea2391519d44508878566fd038a9..c123d2401b279370bb865be89bf6149e29508aff 100644 (file)
@@ -1,7 +1,7 @@
 #![crate_id="cargo-verify-project"]
 #![allow(deprecated_owned_vector)]
 
-extern crate toml;
+extern crate toml = "github.com/mneumann/rust-toml#toml";
 extern crate getopts;
 
 use std::os::{args,set_exit_status};
index 54af358cbd3301bb5f786e089ba711a5fd51000f..cdec169670a75df43ac61670b768a80f13f53227 100644 (file)
@@ -1,7 +1,7 @@
 #![feature(phase)]
 
 extern crate cargo;
-extern crate toml;
+extern crate toml = "github.com/mneumann/rust-toml#toml";
 extern crate hammer;
 extern crate serialize;
 #[phase(syntax, link)]
index 6f11427ecc09e5b90d4f139b8040122768042e96..94aa0f2783664a123e24ba456d1aa8b5ef685209 100644 (file)
@@ -9,7 +9,7 @@ extern crate url;
 extern crate serialize;
 extern crate semver;
 extern crate hammer;
-extern crate toml;
+extern crate toml = "github.com/mneumann/rust-toml#toml";
 
 #[phase(syntax, link)]
 extern crate log;
index 96cd19ab73ae315420dc86071f205a5a9ae8bf39..282eb0dd16b2509e0a78c36c1a53c4a7d7cc9407 100644 (file)
@@ -21,7 +21,7 @@ static CARGO_INTEGRATION_TEST_DIR : &'static str = "cargo-integration-tests";
  *
  */
 
-#[deriving(Eq,Clone)]
+#[deriving(PartialEq,Clone)]
 struct FileBuilder {
     path: Path,
     body: String
@@ -48,7 +48,7 @@ impl FileBuilder {
     }
 }
 
-#[deriving(Eq,Clone)]
+#[deriving(PartialEq,Clone)]
 struct ProjectBuilder {
     name: String,
     root: Path,
@@ -150,13 +150,52 @@ pub fn cargo_dir() -> Path {
         .unwrap_or_else(|| fail!("CARGO_BIN_PATH wasn't set. Cannot continue running test"))
 }
 
+/// Returns an absolute path in the filesystem that `path` points to. The
+/// returned path does not contain any symlinks in its hierarchy.
+pub fn realpath(original: &Path) -> io::IoResult<Path> {
+    static MAX_LINKS_FOLLOWED: uint = 256;
+    let original = os::make_absolute(original);
+
+    // Right now lstat on windows doesn't work quite well
+    if cfg!(windows) {
+        return Ok(original)
+    }
+
+    let result = original.root_path();
+    let mut result = result.expect("make_absolute has no root_path");
+    let mut followed = 0;
+
+    for part in original.components() {
+        result.push(part);
+
+        loop {
+            if followed == MAX_LINKS_FOLLOWED {
+                return Err(io::standard_error(io::InvalidInput))
+            }
+
+            match fs::lstat(&result) {
+                Err(..) => break,
+                Ok(ref stat) if stat.kind != io::TypeSymlink => break,
+                Ok(..) => {
+                    followed += 1;
+                    let path = try!(fs::readlink(&result));
+                    result.pop();
+                    result.push(path);
+                }
+            }
+        }
+    }
+
+    return Ok(result);
+}
+
 /*
  *
  * ===== Matchers =====
  *
  */
 
-#[deriving(Clone,Eq)]
+#[deriving(Clone)]
 struct Execs {
     expect_stdout: Option<String>,
     expect_stdin: Option<String>,
@@ -248,7 +287,7 @@ pub fn execs() -> Box<Execs> {
     }
 }
 
-#[deriving(Clone,Eq)]
+#[deriving(Clone)]
 struct ShellWrites {
     expected: String
 }
index b4d990590d9c05af69af5b48a1761977c59438d0..15d3a659fc6bc0eb9a608568b0a28a4740989d3e 100644 (file)
@@ -1,4 +1,4 @@
-use support::{ResultTest,project,execs};
+use support::{ResultTest,project,execs,realpath};
 use hamcrest::{assert_that,existing_file};
 use cargo;
 use cargo::util::process;
@@ -59,7 +59,7 @@ test!(cargo_compile_with_invalid_code {
         .file("Cargo.toml", basic_bin_manifest("foo").as_slice())
         .file("src/foo.rs", "invalid rust code!");
 
-    let target = p.root().join("target");
+    let target = realpath(&p.root().join("target")).assert();
 
     assert_that(p.cargo_process("cargo-compile"),
         execs()