Make CARGO_BIN_PATH optional for tests

This allows easier use of running tests by hand.
This commit is contained in:
Alex Crichton 2014-06-18 13:14:56 -07:00
parent 3433a01eba
commit fbfa8bdeca
2 changed files with 6 additions and 4 deletions

View File

@ -61,7 +61,7 @@ test-unit: target/tests/test-unit
target/tests/test-unit $(only)
test-integration: target/tests/test-integration
RUST_TEST_TASKS=1 CARGO_BIN_PATH=$(PWD)/target/ $< $(only)
RUST_TEST_TASKS=1 $< $(only)
test: test-unit test-integration

View File

@ -163,9 +163,11 @@ impl<T, E: Show> ErrMsg<T> for Result<T, E> {
// Path to cargo executables
pub fn cargo_dir() -> Path {
os::getenv("CARGO_BIN_PATH")
.map(|s| Path::new(s))
.unwrap_or_else(|| fail!("CARGO_BIN_PATH wasn't set. Cannot continue running test"))
os::getenv("CARGO_BIN_PATH").map(Path::new)
.or_else(|| os::self_exe_path().map(|p| p.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