nextest_runner/
run_mode.rs

1// Copyright (c) The nextest Contributors
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Run mode for nextest.
5
6use std::fmt;
7
8/// The run mode for nextest.
9///
10/// This is used to distinguish between running tests and benchmarks.
11#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
12pub enum NextestRunMode {
13    /// Run tests.
14    #[default]
15    Test,
16    /// Run benchmarks.
17    Benchmark,
18}
19
20impl NextestRunMode {
21    /// Returns true if this is benchmark mode.
22    pub fn is_benchmark(self) -> bool {
23        matches!(self, Self::Benchmark)
24    }
25}
26
27impl fmt::Display for NextestRunMode {
28    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29        match self {
30            Self::Test => write!(f, "test"),
31            Self::Benchmark => write!(f, "benchmark"),
32        }
33    }
34}