process: Fix testing setup

This commit is contained in:
Vicki Pfau 2024-04-04 20:01:59 -07:00
parent cf962b26c5
commit 7e16f2978f
2 changed files with 49 additions and 5 deletions

View file

@ -1,5 +1,5 @@
use anyhow::{anyhow, Result};
use std::cell::RefCell;
use std::cell::{Cell, RefCell};
use std::ffi::OsStr;
use std::path::Path;
use std::rc::Rc;
@ -14,7 +14,7 @@ pub fn start() -> TestHandle {
assert!(lock.borrow().as_ref().is_none());
let test: Rc<Test> = Rc::new(Test {
base: tempdir().expect("Couldn't create test directory"),
process_cb: |_, _| Err(anyhow!("No current process_cb")),
process_cb: Cell::new(|_, _| Err(anyhow!("No current process_cb"))),
});
*lock.borrow_mut() = Some(test.clone());
TestHandle { test }
@ -31,7 +31,7 @@ pub fn current() -> Rc<Test> {
pub struct Test {
base: TempDir,
pub process_cb: fn(&str, &[&OsStr]) -> Result<(i32, String)>,
pub process_cb: Cell<fn(&str, &[&OsStr]) -> Result<(i32, String)>>,
}
pub struct TestHandle {