Skip to content

Commit

Permalink
Test to verify that panicing workloads fail task.
Browse files Browse the repository at this point in the history
  • Loading branch information
bittrance committed Oct 31, 2023
1 parent ae0bafd commit 15e0bd5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::{path::PathBuf, fmt::Debug};

use thiserror::Error;

Expand Down
12 changes: 11 additions & 1 deletion src/task/scheduled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<W: Workload + Clone + Send + 'static> ScheduledTask<W> {
.take()
.expect("result only called once")
.join()
.unwrap()?;
.expect("thread not to panic")?;
self.state.current_sha = new_sha;
Ok(())
}
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 15e0bd5

Please sign in to comment.