#![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};
*
*/
-#[deriving(Eq,Clone)]
+#[deriving(PartialEq,Clone)]
struct FileBuilder {
path: Path,
body: String
}
}
-#[deriving(Eq,Clone)]
+#[deriving(PartialEq,Clone)]
struct ProjectBuilder {
name: String,
root: 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>,
}
}
-#[deriving(Clone,Eq)]
+#[deriving(Clone)]
struct ShellWrites {
expected: String
}
-use support::{ResultTest,project,execs};
+use support::{ResultTest,project,execs,realpath};
use hamcrest::{assert_that,existing_file};
use cargo;
use cargo::util::process;
.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()