diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-07-26 13:14:27 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-07-26 14:50:48 +0200 |
commit | f6e51da4cf954475bb7ab78464f996349fe52e69 (patch) | |
tree | 6ae691fff35e7235f3bd173661f8e357f03ea003 /ffi/tests | |
parent | 8ea27b527f3a9504dfd3ee83c6e0eb60b84cb5c0 (diff) |
ffi: Make sure the shared object is built before running doctests.
Diffstat (limited to 'ffi/tests')
-rw-r--r-- | ffi/tests/c-tests.rs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/ffi/tests/c-tests.rs b/ffi/tests/c-tests.rs index 6f5bdf29..3518e031 100644 --- a/ffi/tests/c-tests.rs +++ b/ffi/tests/c-tests.rs @@ -21,9 +21,14 @@ fn c_doctests() { ); let src = ffi.join("src"); let include = ffi.join("include"); - let debug = ffi.parent().unwrap().join("target").join("debug"); - let target = ffi.parent().unwrap().join("target").join("c-tests"); + let base = ffi.parent().unwrap(); + let debug = base.join("target").join("debug"); + let target = base.join("target").join("c-tests"); fs::create_dir_all(&target).unwrap(); + + // First of all, make sure the shared object is built. + build_so(base).unwrap(); + let mut n = 0; let mut passed = 0; for_all_rs(&src, |path| { @@ -51,6 +56,21 @@ fn c_doctests() { } } +/// Builds the shared object. +fn build_so(base: &Path) -> io::Result<()> { + let st = Command::new("cargo") + .current_dir(base) + .arg("build") + .arg("-p") + .arg("sequoia-ffi") + .status().unwrap(); + if ! st.success() { + return Err(io::Error::new(io::ErrorKind::Other, "compilation failed")); + } + + Ok(()) +} + /// Maps the given function `fun` over all Rust files in `src`. fn for_all_rs<F>(src: &Path, mut fun: F) -> io::Result<()> |