diff --git a/libs/hamcrest-rust b/libs/hamcrest-rust index 822fc1601..a3844d6e0 160000 --- a/libs/hamcrest-rust +++ b/libs/hamcrest-rust @@ -1 +1 @@ -Subproject commit 822fc16016ccd5d24ba460d141e8f2d17db883a0 +Subproject commit a3844d6e0c6b84934078b7ee0e6e702c59cc5242 diff --git a/src/bin/cargo-verify-project.rs b/src/bin/cargo-verify-project.rs index 92d23568a..c123d2401 100644 --- a/src/bin/cargo-verify-project.rs +++ b/src/bin/cargo-verify-project.rs @@ -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}; diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 54af358cb..cdec16967 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -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)] diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 6f11427ec..94aa0f278 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -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; diff --git a/tests/support.rs b/tests/support.rs index 96cd19ab7..282eb0dd1 100644 --- a/tests/support.rs +++ b/tests/support.rs @@ -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 { + 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, expect_stdin: Option, @@ -248,7 +287,7 @@ pub fn execs() -> Box { } } -#[deriving(Clone,Eq)] +#[deriving(Clone)] struct ShellWrites { expected: String } diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index b4d990590..15d3a659f 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -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()