Track master for tests

This commit is contained in:
Yehuda Katz + Carl Lerche 2014-06-09 13:08:09 -07:00 committed by Tim Carey-Smith
parent af91d698f1
commit 9a1c63ea17
6 changed files with 49 additions and 10 deletions

@ -1 +1 @@
Subproject commit 822fc16016ccd5d24ba460d141e8f2d17db883a0
Subproject commit a3844d6e0c6b84934078b7ee0e6e702c59cc5242

View 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};

View 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)]

View 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;

View 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
}

View 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()