notmuch: add integration test to attempt to exhaustively walk messages.
This commit is contained in:
53
notmuch/tests/allmail.rs
Normal file
53
notmuch/tests/allmail.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
use std::{
|
||||
error::Error,
|
||||
io::{stdout, Write},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use rayon::iter::{ParallelBridge, ParallelIterator};
|
||||
|
||||
use notmuch::{Notmuch, NotmuchError, SearchSummary, ThreadSet};
|
||||
|
||||
#[test]
|
||||
fn parse() -> Result<(), Box<dyn Error>> {
|
||||
// take_hook() returns the default hook in case when a custom one is not set
|
||||
let orig_hook = std::panic::take_hook();
|
||||
std::panic::set_hook(Box::new(move |panic_info| {
|
||||
// invoke the default handler and exit the process
|
||||
orig_hook(panic_info);
|
||||
std::process::exit(1);
|
||||
}));
|
||||
|
||||
let nm = Notmuch::default();
|
||||
let count = nm.count("*")? as f32;
|
||||
let start = Instant::now();
|
||||
nm.message_ids("*")?
|
||||
.enumerate()
|
||||
.par_bridge()
|
||||
.for_each(|(i, msg)| {
|
||||
let msg = msg.expect("failed to unwrap msg");
|
||||
let ts = nm
|
||||
.show(&msg)
|
||||
.expect(&format!("failed to show msg: {}", msg));
|
||||
//println!("{:?}", ts);
|
||||
if i > 0 && i % 1000 == 0 {
|
||||
let diff = start.elapsed();
|
||||
let percent = (i as f32 * 100.) / count;
|
||||
let eta = diff.mul_f32(count as f32).div_f32(i as f32);
|
||||
print!(
|
||||
"\nElapsed {}s ETA {}s Percent {}% ",
|
||||
diff.as_secs_f32(),
|
||||
eta.as_secs_f32(),
|
||||
percent
|
||||
);
|
||||
stdout().flush().expect("failed to flush stdout");
|
||||
}
|
||||
if i % 10 == 0 {
|
||||
print!(".");
|
||||
stdout().flush().expect("failed to flush stdout");
|
||||
}
|
||||
});
|
||||
println!("\n");
|
||||
assert!(false);
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user