]> git.lizzy.rs Git - rust.git/blob - src/libtest/options.rs
Split libtest into several smaller modules
[rust.git] / src / libtest / options.rs
1 //! Enums denoting options for test execution.
2
3 /// Whether to execute tests concurrently or not
4 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
5 pub enum Concurrent {
6     Yes,
7     No,
8 }
9
10 #[derive(Clone, PartialEq, Eq)]
11 pub enum BenchMode {
12     Auto,
13     Single,
14 }
15
16 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
17 pub enum ShouldPanic {
18     No,
19     Yes,
20     YesWithMessage(&'static str),
21 }
22
23 #[derive(Copy, Clone, Debug)]
24 pub enum ColorConfig {
25     AutoColor,
26     AlwaysColor,
27     NeverColor,
28 }
29
30 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
31 pub enum OutputFormat {
32     Pretty,
33     Terse,
34     Json,
35 }
36
37 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
38 pub enum RunIgnored {
39     Yes,
40     No,
41     Only,
42 }
43
44 #[derive(Clone, Copy)]
45 pub enum RunStrategy {
46     /// Runs the test in the current process, and sends the result back over the
47     /// supplied channel.
48     InProcess,
49
50     /// Spawns a subprocess to run the test, and sends the result back over the
51     /// supplied channel. Requires `argv[0]` to exist and point to the binary
52     /// that's currently running.
53     SpawnPrimary,
54 }
55
56 /// In case we want to add other options as well, just add them in this struct.
57 #[derive(Copy, Clone, Debug)]
58 pub struct Options {
59     pub display_output: bool,
60     pub panic_abort: bool,
61 }
62
63 impl Options {
64     pub fn new() -> Options {
65         Options {
66             display_output: false,
67             panic_abort: false,
68         }
69     }
70
71     pub fn display_output(mut self, display_output: bool) -> Options {
72         self.display_output = display_output;
73         self
74     }
75
76     pub fn panic_abort(mut self, panic_abort: bool) -> Options {
77         self.panic_abort = panic_abort;
78         self
79     }
80 }