diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-04-24 16:53:13 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-04-24 16:53:47 +0200 |
commit | 446ec50b488a1a16401d3cd8155d75a2fad41cbe (patch) | |
tree | 19b7649242fecadf271bb400fe515a7d5367a346 /openpgp/tests | |
parent | 4517d67f0a7d0c3722fa6ba2197098dff7e3b026 (diff) |
openpgp: Improve test.
Diffstat (limited to 'openpgp/tests')
-rw-r--r-- | openpgp/tests/for-each-artifact.rs | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/openpgp/tests/for-each-artifact.rs b/openpgp/tests/for-each-artifact.rs index d8728a09..d1744dd5 100644 --- a/openpgp/tests/for-each-artifact.rs +++ b/openpgp/tests/for-each-artifact.rs @@ -17,7 +17,7 @@ mod for_each_artifact { let mut v = Vec::new(); p.serialize(&mut v)?; let q = openpgp::Packet::from_bytes(&v)?; - assert_eq!(p, &q); + assert_eq!(p, &q, "roundtripping {:?} failed", src); Ok(()) }) }).unwrap(); @@ -47,8 +47,8 @@ mod for_each_artifact { #[test] fn message_roundtrip() { for_all_files(&test_data_dir(), |src| { - let p = if let Ok(tpk) = openpgp::Message::from_file(src) { - tpk + let p = if let Ok(msg) = openpgp::Message::from_file(src) { + msg } else { // Ignore non-Message files. return Ok(()); @@ -84,6 +84,23 @@ fn for_all_files<F>(src: &Path, mut fun: F) -> openpgp::Result<()> let entry = entry?; let path = entry.path(); if path.is_file() { + // XXX: Look at the file extension and skip non-PGP + // files. We need to do this because the + // Armor-heuristic is so slow. See #204. + if let Some(extension) = + path.extension().and_then(|e| e.to_str()) + { + match extension { + "pgp" | "gpg" | "asc" | "key" => (), + e if e.contains("key") => (), + _ => continue, + } + } else { + // No extension or not valid UTF-8. + continue; + } + + eprintln!("Processing {:?}", path); match fun(&path) { Ok(_) => (), Err(e) => { |