summaryrefslogtreecommitdiffstats
path: root/ffi
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-03-13 14:03:57 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-03-13 14:31:36 +0100
commitf9aa80d1adb056091e4d12d8d042b54750348d61 (patch)
tree690ea0289b2d72a43b23eb1aba115855b3aa11db /ffi
parent99372c3021b5a5900b96ccefde48a3f43ee1127b (diff)
openpgp-ffi, ffi: Prevent capturing of c-tests's output.
- By explicitly printing to stderr, we can avoid the test's output from being captured by Rust's test framework.
Diffstat (limited to 'ffi')
-rw-r--r--ffi/tests/c-tests.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/ffi/tests/c-tests.rs b/ffi/tests/c-tests.rs
index 4df61903..7670f13b 100644
--- a/ffi/tests/c-tests.rs
+++ b/ffi/tests/c-tests.rs
@@ -13,7 +13,9 @@ use std::mem::replace;
/// Hooks into Rust's test system to extract, compile and run c tests.
#[test]
-fn c_doctests() {
+fn c_doctests() -> Result<()> {
+ let stderr = &mut io::stderr();
+
// The location of this crate's (i.e., the ffi crate's) source.
let manifest_dir = PathBuf::from(
var_os("CARGO_MANIFEST_DIR")
@@ -50,30 +52,31 @@ fn c_doctests() {
for_all_rs(&src, |path| {
for_all_tests(path, |src, lineno, name, lines, run_it| {
n += 1;
- eprint!(" test {} ... ", name);
+ write!(stderr, " test {} ... ", name)?;
match build(&includes, &debug, &target, src, lineno, name, lines) {
Ok(_) if ! run_it => {
- eprintln!("ok");
+ writeln!(stderr, "ok")?;
passed += 1;
},
Ok(exe) => match run(&debug, &exe) {
Ok(()) => {
- eprintln!("ok");
+ writeln!(stderr, "ok")?;
passed += 1;
},
Err(e) =>
- eprintln!("{}", e),
+ writeln!(stderr, "{}", e)?,
},
Err(e) =>
- eprintln!("{}", e),
+ writeln!(stderr, "{}", e)?,
}
Ok(())
})
}).unwrap();
- eprintln!(" test result: {} passed; {} failed", passed, n - passed);
+ writeln!(stderr, " test result: {} passed; {} failed", passed, n - passed)?;
if n != passed {
panic!("ffi test failures");
}
+ Ok(())
}
/// Builds the shared object.