diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-03-13 14:03:57 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-03-13 14:31:36 +0100 |
commit | f9aa80d1adb056091e4d12d8d042b54750348d61 (patch) | |
tree | 690ea0289b2d72a43b23eb1aba115855b3aa11db /openpgp-ffi/tests | |
parent | 99372c3021b5a5900b96ccefde48a3f43ee1127b (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 'openpgp-ffi/tests')
-rw-r--r-- | openpgp-ffi/tests/c-tests.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/openpgp-ffi/tests/c-tests.rs b/openpgp-ffi/tests/c-tests.rs index e58fff52..aba29a28 100644 --- a/openpgp-ffi/tests/c-tests.rs +++ b/openpgp-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") @@ -49,30 +51,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. |