eval_stack/
config.rs

1use std::{path::PathBuf, time::Duration};
2
3#[derive(Debug, Clone)]
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[serde(rename_all = "camelCase")]
6pub struct JudgeOptions {
7    /// Maximum time limit in seconds.
8    pub time_limit: Duration,
9    /// Maximum memory usage in bytes.
10    pub memory_limit: u64,
11    /// Stop running tests after the first failure.
12    ///
13    /// Enable this option for ICPC mode contests.
14    /// Defaults to `true`.
15    pub fail_fast: bool,
16    /// Disable setting `RLIMIT_AS` and `seccomp` filter.
17    pub no_startup_limits: bool,
18    /// Run without kernel-level sand-boxing.
19    pub unsafe_mode: bool,
20}
21
22impl Default for JudgeOptions {
23    fn default() -> Self {
24        Self {
25            time_limit: Duration::from_secs(1),
26            memory_limit: 128 * 1024 * 1024,
27            fail_fast: true,
28            no_startup_limits: false,
29            unsafe_mode: false,
30        }
31    }
32}
33
34impl JudgeOptions {
35    pub fn fail_fast(mut self, fail_fast: bool) -> Self {
36        self.fail_fast = fail_fast;
37        self
38    }
39
40    pub fn no_fail_fast(self) -> Self {
41        self.fail_fast(false)
42    }
43
44    pub fn no_startup_limits(mut self, no_startup_limits: bool) -> Self {
45        self.no_startup_limits = no_startup_limits;
46        self
47    }
48}
49
50pub struct TestCase<I, O>
51where
52    I: Into<PathBuf>,
53    O: Into<PathBuf>,
54{
55    pub input_file: I,
56    pub expected_output_file: O,
57}