diff options
author | Neal H. Walfield <neal@pep.foundation> | 2018-07-28 10:45:24 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2018-07-28 10:46:38 +0200 |
commit | 0a9a235fdefe58bd744d9fedac1f373e1a4caf8b (patch) | |
tree | 107d85e112f5878e57a1b60115e0b5c9b9331239 /ffi/tests/c-tests.rs | |
parent | da1ff028ea8ed7f00fa1c705382c37d90042c73b (diff) |
ffi: Support builds that use CARGO_TARGET_DIR.
- If CARGO_TARGET_DIR is set, then the tests looked for the
libraries in the wrong spot, and wrote the tests to the wrong
location.
Diffstat (limited to 'ffi/tests/c-tests.rs')
-rw-r--r-- | ffi/tests/c-tests.rs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/ffi/tests/c-tests.rs b/ffi/tests/c-tests.rs index 850914a1..549f65c1 100644 --- a/ffi/tests/c-tests.rs +++ b/ffi/tests/c-tests.rs @@ -19,20 +19,26 @@ use nettle::hash::{Hash, Sha256}; /// Hooks into Rust's test system to extract, compile and run c tests. #[test] fn c_doctests() { - let ffi = PathBuf::from( + let manifest_dir = PathBuf::from( var_os("CARGO_MANIFEST_DIR") - .as_ref() - .expect("CARGO_MANIFEST_DIR not set") - ); - let src = ffi.join("src"); - let include = ffi.join("include"); - let base = ffi.parent().unwrap(); - let debug = base.join("target").join("debug"); - let target = base.join("target").join("c-tests"); + .as_ref() + .expect("CARGO_MANIFEST_DIR not set")); + + let src = manifest_dir.join("src"); + let include = manifest_dir.join("include"); + + let target_dir = if let Some(dir) = var_os("CARGO_TARGET_DIR") { + PathBuf::from(dir) + } else { + manifest_dir.join("target") + }; + + let debug = target_dir.join("debug"); + let target = target_dir.join("c-tests"); fs::create_dir_all(&target).unwrap(); // First of all, make sure the shared object is built. - build_so(base).unwrap(); + build_so(&manifest_dir).unwrap(); let mut n = 0; let mut passed = 0; |