libtest2_harness/
state.rs

1pub(crate) use crate::*;
2
3#[derive(Debug)]
4pub struct State {
5    mode: RunMode,
6    run_ignored: bool,
7}
8
9impl State {
10    pub fn ignore(&self) -> Result<(), RunError> {
11        if self.run_ignored {
12            Ok(())
13        } else {
14            Err(RunError::ignore())
15        }
16    }
17
18    pub fn ignore_for(&self, reason: impl std::fmt::Display) -> Result<(), RunError> {
19        if self.run_ignored {
20            Ok(())
21        } else {
22            Err(RunError::ignore_for(reason.to_string()))
23        }
24    }
25
26    pub fn current_mode(&self) -> RunMode {
27        self.mode
28    }
29}
30
31impl State {
32    pub(crate) fn new() -> Self {
33        Self {
34            mode: Default::default(),
35            run_ignored: false,
36        }
37    }
38
39    pub(crate) fn set_mode(&mut self, mode: RunMode) {
40        self.mode = mode;
41    }
42
43    pub(crate) fn set_run_ignored(&mut self, yes: bool) {
44        self.run_ignored = yes;
45    }
46}