diff --git a/src/errors.rs b/src/errors.rs index 0f51ae9..17fc971 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::{path::PathBuf, fmt::Debug}; use thiserror::Error; diff --git a/src/task/scheduled.rs b/src/task/scheduled.rs index a610ee7..c6a97f1 100644 --- a/src/task/scheduled.rs +++ b/src/task/scheduled.rs @@ -61,7 +61,7 @@ impl ScheduledTask { .take() .expect("result only called once") .join() - .unwrap()?; + .expect("thread not to panic")?; self.state.current_sha = new_sha; Ok(()) } @@ -113,6 +113,16 @@ mod tests { task.await_eligible(); } + #[test] + #[should_panic] + fn scheduled_task_on_panic() { + let mut task = ScheduledTask::new(TestWorkload::fail_with(|| panic!("BOOM!"))); + task.start().unwrap(); + task.await_finished(); + assert!(!task.is_running()); + task.finalize().unwrap(); + } + #[test] fn scheduled_task_on_existing_state() { let mut task = ScheduledTask::new(TestWorkload::default());