Skip to main content

relux_runtime/
runtime_context.rs

1use std::path::Path;
2use std::sync::Arc;
3use std::time::Instant;
4
5use tokio_util::sync::CancellationToken;
6
7use crate::observe::event_sink::EventSink;
8use crate::observe::shell_log::ShellLogger;
9use relux_core::pure::LayeredEnv;
10use relux_ir::IrTimeout;
11use relux_ir::Tables;
12
13#[derive(Clone, Debug)]
14pub struct ShellConfig {
15    pub command: Arc<str>,
16    pub prompt: Arc<str>,
17    pub default_timeout: IrTimeout,
18}
19
20#[derive(Clone)]
21pub struct RuntimeContext {
22    pub events: EventSink,
23    pub shell: ShellConfig,
24    pub log_dir: Arc<Path>,
25    pub tables: Tables,
26    pub env: Arc<LayeredEnv>,
27    pub cancel: CancellationToken,
28    pub test_start: Instant,
29    pub flaky_timeout_multiplier: f64,
30}
31
32impl RuntimeContext {
33    pub fn create_shell_logger(&self, name: &str) -> std::io::Result<ShellLogger> {
34        ShellLogger::create(&self.log_dir, name, self.test_start)
35    }
36}