bootstrap/core/build_steps/test/
compiletest.rs

1use std::fmt;
2
3/// Enum of all the "test modes" understood by compiletest.
4///
5/// Some of these mode names happen to overlap with the names of test suite
6/// directories, but the relationship between modes and suites is not 1:1.
7/// For example:
8/// - Mode `ui` is used by suites `tests/ui` and `tests/rustdoc-ui`
9/// - Suite `tests/coverage` uses modes `coverage-map` and `coverage-run`
10#[derive(Clone, Copy, PartialEq, Eq, Hash)]
11pub(crate) enum CompiletestMode {
12    // tidy-alphabetical-start
13    Assembly,
14    Codegen,
15    CodegenUnits,
16    CoverageMap,
17    CoverageRun,
18    Crashes,
19    Debuginfo,
20    Incremental,
21    MirOpt,
22    Pretty,
23    RunMake,
24    Rustdoc,
25    RustdocJs,
26    RustdocJson,
27    Ui,
28    // tidy-alphabetical-end
29}
30
31impl CompiletestMode {
32    /// Returns a string representing this mode, which can be passed to
33    /// compiletest via a command-line argument.
34    ///
35    /// These mode names must be kept in sync with the ones understood by
36    /// compiletest's `TestMode`, but they change so rarely that doing so
37    /// manually should not be burdensome.
38    pub(crate) const fn as_str(self) -> &'static str {
39        match self {
40            // tidy-alphabetical-start
41            Self::Assembly => "assembly",
42            Self::Codegen => "codegen",
43            Self::CodegenUnits => "codegen-units",
44            Self::CoverageMap => "coverage-map",
45            Self::CoverageRun => "coverage-run",
46            Self::Crashes => "crashes",
47            Self::Debuginfo => "debuginfo",
48            Self::Incremental => "incremental",
49            Self::MirOpt => "mir-opt",
50            Self::Pretty => "pretty",
51            Self::RunMake => "run-make",
52            Self::Rustdoc => "rustdoc",
53            Self::RustdocJs => "rustdoc-js",
54            Self::RustdocJson => "rustdoc-json",
55            Self::Ui => "ui",
56            // tidy-alphabetical-end
57        }
58    }
59}
60
61impl fmt::Display for CompiletestMode {
62    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
63        f.write_str(self.as_str())
64    }
65}
66
67impl fmt::Debug for CompiletestMode {
68    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
69        <Self as fmt::Display>::fmt(self, f)
70    }
71}