1//! Enums denoting options for test execution.
2
3/// Number of times to run a benchmarked function
4#[derive(Clone, PartialEq, Eq)]
5pub enum BenchMode {
6 Auto,
7 Single,
8}
9
10/// Whether test is expected to panic or not
11#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
12pub enum ShouldPanic {
13 No,
14 Yes,
15 YesWithMessage(&'static str),
16}
17
18/// Whether should console output be colored or not
19#[derive(Copy, Clone, Default, Debug)]
20pub enum ColorConfig {
21 #[default]
22 AutoColor,
23 AlwaysColor,
24 NeverColor,
25}
26
27/// Format of the test results output
28#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
29pub enum OutputFormat {
30 /// Verbose output
31 Pretty,
32 /// Quiet output
33 #[default]
34 Terse,
35 /// JSON output
36 Json,
37 /// JUnit output
38 Junit,
39}
40
41/// Whether ignored test should be run or not
42#[derive(Copy, Clone, Debug, PartialEq, Eq)]
43pub enum RunIgnored {
44 Yes,
45 No,
46 /// Run only ignored tests
47 Only,
48}
49
50#[derive(Clone, Copy)]
51pub enum RunStrategy {
52 /// Runs the test in the current process, and sends the result back over the
53 /// supplied channel.
54 InProcess,
55
56 /// Spawns a subprocess to run the test, and sends the result back over the
57 /// supplied channel. Requires `argv[0]` to exist and point to the binary
58 /// that's currently running.
59 SpawnPrimary,
60}
61
62/// Options for the test run defined by the caller (instead of CLI arguments).
63/// In case we want to add other options as well, just add them in this struct.
64#[derive(Copy, Clone, Debug)]
65pub struct Options {
66 pub display_output: bool,
67 pub panic_abort: bool,
68}
69
70impl Options {
71 pub fn new() -> Options {
72 Options { display_output: false, panic_abort: false }
73 }
74
75 pub fn display_output(mut self, display_output: bool) -> Options {
76 self.display_output = display_output;
77 self
78 }
79
80 pub fn panic_abort(mut self, panic_abort: bool) -> Options {
81 self.panic_abort = panic_abort;
82 self
83 }
84}
85