1use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5use std::{
6 collections::{HashMap, HashSet},
7 path::PathBuf,
8};
9
10#[derive(Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash)]
12#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
13pub struct TestDesc {
14 pub name: String,
19 pub points: Vec<String>,
23}
24
25impl TestDesc {
26 pub fn new(name: String, points: Vec<String>) -> Self {
27 Self { name, points }
28 }
29}
30
31#[derive(Debug, Deserialize, Serialize, JsonSchema)]
33#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
34pub struct TestResult {
35 pub name: String,
36 pub successful: bool,
37 pub points: Vec<String>,
39 pub message: String,
40 #[serde(default)]
41 pub exception: Vec<String>,
42}
43
44#[derive(Debug, Deserialize, Serialize, JsonSchema)]
46#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
47pub struct ExerciseDesc {
48 pub name: String,
51 pub tests: Vec<TestDesc>,
53}
54
55impl ExerciseDesc {
56 pub fn new(name: String, tests: Vec<TestDesc>) -> Self {
57 Self { name, tests }
58 }
59}
60
61#[derive(Debug, Deserialize, Serialize, JsonSchema)]
63#[serde(rename_all = "camelCase")]
64#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
65pub struct RunResult {
66 pub status: RunStatus,
68 pub test_results: Vec<TestResult>,
70 pub logs: HashMap<String, String>,
73}
74
75impl RunResult {
76 pub fn new(
77 status: RunStatus,
78 test_results: Vec<TestResult>,
79 logs: HashMap<String, String>,
80 ) -> Self {
81 Self {
82 status,
83 test_results,
84 logs,
85 }
86 }
87}
88
89#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
91#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
92#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
93pub enum RunStatus {
94 Passed,
96 TestsFailed,
98 CompileFailed,
101 TestrunInterrupted,
103 GenericError,
107}
108
109#[derive(Debug, Deserialize, Serialize, JsonSchema)]
111#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
112pub struct ExercisePackagingConfiguration {
113 pub student_file_paths: HashSet<PathBuf>,
115 pub exercise_file_paths: HashSet<PathBuf>,
117}
118
119impl ExercisePackagingConfiguration {
120 pub fn new(
121 student_file_paths: HashSet<PathBuf>,
122 exercise_file_paths: HashSet<PathBuf>,
123 ) -> Self {
124 Self {
125 student_file_paths,
126 exercise_file_paths,
127 }
128 }
129}
130
131#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
133#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
134#[serde(rename_all = "UPPERCASE")]
135pub enum StyleValidationStrategy {
136 Fail,
137 Warn,
138 Disabled,
139}
140
141#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
143#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
144pub struct StyleValidationError {
145 pub column: u32,
146 pub line: u32,
147 pub message: String,
148 pub source_name: String,
149}
150
151#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
153#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
154pub struct StyleValidationResult {
155 pub strategy: StyleValidationStrategy,
156 pub validation_errors: Option<HashMap<PathBuf, Vec<StyleValidationError>>>,
157}