Make CARGO_BIN_PATH optional for tests
authorAlex Crichton <alex@alexcrichton.com>
Wed, 18 Jun 2014 20:14:56 +0000 (13:14 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 19 Jun 2014 18:52:51 +0000 (11:52 -0700)
This allows easier use of running tests by hand.

Makefile
tests/support/mod.rs

index 256ef9cf923276e2056f903eac43a90f18d98097..216af20e062c5e8811e65921a0c9340b4fa305f3 100644 (file)
--- 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
 
index a976a158d3f85ffd4783d4e40ae871ea1130f9d0..d045beb8ab32ca0cac25c5d1dfa91b78ad94b38b 100644 (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