Skip to repository content53 lines · 1.6 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T04:44:04.708Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
evals.rs
1#[cfg(all(test, feature = "unit-eval"))]
2use futures::future::LocalBoxFuture;
3#[cfg(all(test, feature = "unit-eval"))]
4use gpui::TestAppContext;
5#[cfg(all(test, feature = "unit-eval"))]
6use std::fmt::Display;
7
8#[cfg(all(test, feature = "unit-eval"))]
9mod edit_file;
10#[cfg(all(test, feature = "unit-eval"))]
11mod terminal_tool;
12#[cfg(all(test, feature = "unit-eval"))]
13mod write_file;
14
15#[cfg(all(test, feature = "unit-eval"))]
16fn run_gpui_eval<T>(
17 eval: impl for<'a> FnOnce(&'a mut TestAppContext) -> LocalBoxFuture<'a, anyhow::Result<T>>,
18 outcome: impl FnOnce(&T) -> eval_utils::OutcomeKind,
19) -> eval_utils::EvalOutput<()>
20where
21 T: Display,
22{
23 let dispatcher = gpui::TestDispatcher::new(rand::random());
24 let mut cx = TestAppContext::build(dispatcher.clone(), None);
25 let entity_refcounts = cx.app.borrow().ref_counts_drop_handle();
26 let foreground_executor = cx.foreground_executor().clone();
27 let result = foreground_executor.block_test(eval(&mut cx));
28
29 cx.run_until_parked();
30 cx.update(|cx| {
31 cx.background_executor().forbid_parking();
32 cx.quit();
33 });
34 cx.run_until_parked();
35 drop(cx);
36 dispatcher.drain_tasks();
37 drop(dispatcher);
38 drop(entity_refcounts);
39
40 match result {
41 Ok(output) => eval_utils::EvalOutput {
42 data: output.to_string(),
43 outcome: outcome(&output),
44 metadata: (),
45 },
46 Err(err) => eval_utils::EvalOutput {
47 data: format!("{err:?}"),
48 outcome: eval_utils::OutcomeKind::Error,
49 metadata: (),
50 },
51 }
52}
53