Skip to content

Commit 4c3f9da

Browse files
tilde-engineeringhalorgium
authored andcommitted
Track master for tests
1 parent 7884a61 commit 4c3f9da

File tree

6 files changed

+49
-10
lines changed

6 files changed

+49
-10
lines changed

libs/hamcrest-rust

src/bin/cargo-verify-project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![crate_id="cargo-verify-project"]
22
#![allow(deprecated_owned_vector)]
33

4-
extern crate toml;
4+
extern crate toml = "github.com/mneumann/rust-toml#toml";
55
extern crate getopts;
66

77
use std::os::{args,set_exit_status};

src/bin/cargo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(phase)]
22

33
extern crate cargo;
4-
extern crate toml;
4+
extern crate toml = "github.com/mneumann/rust-toml#toml";
55
extern crate hammer;
66
extern crate serialize;
77
#[phase(syntax, link)]

src/cargo/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern crate url;
99
extern crate serialize;
1010
extern crate semver;
1111
extern crate hammer;
12-
extern crate toml;
12+
extern crate toml = "github.com/mneumann/rust-toml#toml";
1313

1414
#[phase(syntax, link)]
1515
extern crate log;

tests/support.rs

+43-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static CARGO_INTEGRATION_TEST_DIR : &'static str = "cargo-integration-tests";
2121
*
2222
*/
2323

24-
#[deriving(Eq,Clone)]
24+
#[deriving(PartialEq,Clone)]
2525
struct FileBuilder {
2626
path: Path,
2727
body: String
@@ -48,7 +48,7 @@ impl FileBuilder {
4848
}
4949
}
5050

51-
#[deriving(Eq,Clone)]
51+
#[deriving(PartialEq,Clone)]
5252
struct ProjectBuilder {
5353
name: String,
5454
root: Path,
@@ -150,13 +150,52 @@ pub fn cargo_dir() -> Path {
150150
.unwrap_or_else(|| fail!("CARGO_BIN_PATH wasn't set. Cannot continue running test"))
151151
}
152152

153+
/// Returns an absolute path in the filesystem that `path` points to. The
154+
/// returned path does not contain any symlinks in its hierarchy.
155+
pub fn realpath(original: &Path) -> io::IoResult<Path> {
156+
static MAX_LINKS_FOLLOWED: uint = 256;
157+
let original = os::make_absolute(original);
158+
159+
// Right now lstat on windows doesn't work quite well
160+
if cfg!(windows) {
161+
return Ok(original)
162+
}
163+
164+
let result = original.root_path();
165+
let mut result = result.expect("make_absolute has no root_path");
166+
let mut followed = 0;
167+
168+
for part in original.components() {
169+
result.push(part);
170+
171+
loop {
172+
if followed == MAX_LINKS_FOLLOWED {
173+
return Err(io::standard_error(io::InvalidInput))
174+
}
175+
176+
match fs::lstat(&result) {
177+
Err(..) => break,
178+
Ok(ref stat) if stat.kind != io::TypeSymlink => break,
179+
Ok(..) => {
180+
followed += 1;
181+
let path = try!(fs::readlink(&result));
182+
result.pop();
183+
result.push(path);
184+
}
185+
}
186+
}
187+
}
188+
189+
return Ok(result);
190+
}
191+
153192
/*
154193
*
155194
* ===== Matchers =====
156195
*
157196
*/
158197

159-
#[deriving(Clone,Eq)]
198+
#[deriving(Clone)]
160199
struct Execs {
161200
expect_stdout: Option<String>,
162201
expect_stdin: Option<String>,
@@ -248,7 +287,7 @@ pub fn execs() -> Box<Execs> {
248287
}
249288
}
250289

251-
#[deriving(Clone,Eq)]
290+
#[deriving(Clone)]
252291
struct ShellWrites {
253292
expected: String
254293
}

tests/test_cargo_compile.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use support::{ResultTest,project,execs};
1+
use support::{ResultTest,project,execs,realpath};
22
use hamcrest::{assert_that,existing_file};
33
use cargo;
44
use cargo::util::process;
@@ -59,7 +59,7 @@ test!(cargo_compile_with_invalid_code {
5959
.file("Cargo.toml", basic_bin_manifest("foo").as_slice())
6060
.file("src/foo.rs", "invalid rust code!");
6161

62-
let target = p.root().join("target");
62+
let target = realpath(&p.root().join("target")).assert();
6363

6464
assert_that(p.cargo_process("cargo-compile"),
6565
execs()

0 commit comments

Comments
 (0)