diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-03-20 13:32:36 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-03-20 13:55:25 +0100 |
commit | 1ef3b05c63c76cff9e108bf51cbc0b1827c392ea (patch) | |
tree | 2193ef157218c913b5be5d085cacbe0bbb3f7e24 /openpgp-ffi/tests | |
parent | d865c46bfc2c4b6bd25060dacd7d605f26fbdab7 (diff) |
openpgp-ffi: Simplify c-test.
- Use the line number instead of a hash. This makes it simpler, but
also easier to locate the test in the source file.
Diffstat (limited to 'openpgp-ffi/tests')
-rw-r--r-- | openpgp-ffi/tests/c-tests.rs | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/openpgp-ffi/tests/c-tests.rs b/openpgp-ffi/tests/c-tests.rs index 6802de0c..0ec26500 100644 --- a/openpgp-ffi/tests/c-tests.rs +++ b/openpgp-ffi/tests/c-tests.rs @@ -4,7 +4,6 @@ extern crate nettle; use std::cmp::min; use std::env::{self, var_os}; use std::ffi::OsStr; -use std::fmt::Write as FmtWrite; use std::fs; use std::io::{self, BufRead, Write}; use std::os::unix::io::AsRawFd; @@ -14,8 +13,6 @@ use std::str::FromStr; use std::time; use std::mem::replace; -use nettle::hash::{Hash, Sha256}; - /// Hooks into Rust's test system to extract, compile and run c tests. #[test] fn c_doctests() { @@ -176,18 +173,9 @@ fn for_all_tests<F>(path: &Path, mut fun: F) } if line == "//! ```" && test.len() > 0 { - let mut hash = Sha256::default(); - for line in test.iter() { - writeln!(&mut hash as &mut Hash, "{}", line).unwrap(); - } - let mut digest = vec![0; hash.digest_size()]; - hash.digest(&mut digest); - let mut name = String::new(); - write!(&mut name, "{}_", - path.file_stem().unwrap().to_string_lossy()).unwrap(); - for b in digest { - write!(&mut name, "{:02x}", b).unwrap(); - } + let name = format!("{}_{}", + path.file_stem().unwrap().to_string_lossy(), + lineno); // XXX: nicer to point to the top fun(path, test_starts_at, &name, replace(&mut test, Vec::new()), run)?; |