From: Alex Crichton Date: Wed, 18 Jun 2014 20:14:56 +0000 (-0700) Subject: Make CARGO_BIN_PATH optional for tests X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~994^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fbfa8bdeca38bd703f81eba2e086341c764bb116;p=cargo.git Make CARGO_BIN_PATH optional for tests This allows easier use of running tests by hand. --- diff --git a/Makefile b/Makefile index 256ef9cf9..216af20e0 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/tests/support/mod.rs b/tests/support/mod.rs index a976a158d..d045beb8a 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -163,9 +163,11 @@ impl ErrMsg for Result { // 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