ac_algorithm/test_run.rs
1//! Local test runs: one solution executed against one case (or ad-hoc
2//! input) through the job manager.
3
4use std::path::PathBuf;
5use std::time::{Duration, SystemTime};
6
7use serde::{Deserialize, Serialize};
8
9use ac_services::jobs::JobId;
10
11use crate::ids::{CaseId, SolutionId, TestRunId};
12use crate::verdict::LocalVerdict;
13
14/// Lifecycle of a [`TestRun`].
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
16pub enum TestRunStatus {
17 /// Recorded but not yet dispatched to the job manager.
18 Pending,
19 /// Executing under a [`JobId`].
20 Running,
21 /// Finished with a [`LocalVerdict`].
22 Finished,
23 /// The run itself failed (compile error, harness fault, lost job).
24 Failed,
25 /// Cancelled by the user or the session.
26 Cancelled,
27}
28
29/// A single local execution of a solution against a case.
30#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
31pub struct TestRun {
32 /// Run identifier.
33 pub id: TestRunId,
34 /// Solution that was executed.
35 pub solution: SolutionId,
36 /// Case under test, or `None` for ad-hoc input.
37 pub case: Option<CaseId>,
38 /// Job that executes the run, once dispatched (C-06).
39 pub job: Option<JobId>,
40 /// Current lifecycle state.
41 pub status: TestRunStatus,
42 /// Local verdict once finished. Never an official judge result.
43 pub verdict: Option<LocalVerdict>,
44 /// Process exit code, when the run produced one.
45 pub exit_code: Option<i32>,
46 /// Wall-clock duration of the run.
47 pub duration: Option<Duration>,
48 /// Path to captured stdout/stderr log, when retained.
49 pub log_path: Option<PathBuf>,
50 /// When execution started.
51 pub started_at: Option<SystemTime>,
52 /// When execution finished.
53 pub finished_at: Option<SystemTime>,
54}