Skip to content

Commit c44aaff

Browse files
committed
Rename Mode to RunDepMode
1 parent 008326d commit c44aaff

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

tests/ui.rs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use ui_test::spanned::Spanned;
1515
use ui_test::{status_emitter, CommandBuilder, Config, Format, Match, OutputConflictHandling};
1616

1717
#[derive(Copy, Clone, Debug)]
18-
enum Mode {
18+
enum RunDepMode {
1919
Pass,
2020
Fail,
2121
Yolo,
@@ -80,7 +80,7 @@ fn build_native_lib() -> PathBuf {
8080

8181
/// Does *not* set any args or env vars, since it is shared between the test runner and
8282
/// run_dep_mode.
83-
fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) -> Config {
83+
fn miri_config(target: &str, path: &str, mode: RunDepMode, with_dependencies: bool) -> Config {
8484
// Miri is rustc-like, so we create a default builder for rustc and modify it
8585
let mut program = CommandBuilder::rustc();
8686
program.program = miri_path();
@@ -96,20 +96,15 @@ fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
9696
};
9797

9898
config.comment_defaults.base().exit_status = match mode {
99-
Mode::Pass => Some(0_i32),
100-
Mode::Fail => Some(1),
101-
Mode::Yolo => None,
102-
Mode::Panic => Some(101),
99+
RunDepMode::Pass => Some(0_i32),
100+
RunDepMode::Fail => Some(1),
101+
RunDepMode::Yolo => None,
102+
RunDepMode::Panic => Some(101),
103103
}
104104
.map(Spanned::dummy)
105105
.into();
106106

107-
config.comment_defaults.base().require_annotations = Spanned::dummy(match mode {
108-
Mode::Pass => false,
109-
Mode::Fail => true,
110-
Mode::Yolo => false,
111-
Mode::Panic => false,
112-
})
107+
config.comment_defaults.base().require_annotations = Spanned::dummy(matches!(mode, RunDepMode::Fail))
113108
.into();
114109

115110
config.comment_defaults.base().normalize_stderr =
@@ -143,7 +138,7 @@ fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
143138
}
144139

145140
fn run_tests(
146-
mode: Mode,
141+
mode: RunDepMode,
147142
path: &str,
148143
target: &str,
149144
with_dependencies: bool,
@@ -280,7 +275,7 @@ enum Dependencies {
280275
use Dependencies::*;
281276

282277
fn ui(
283-
mode: Mode,
278+
mode: RunDepMode,
284279
path: &str,
285280
target: &str,
286281
with_dependencies: Dependencies,
@@ -316,21 +311,21 @@ fn main() -> Result<()> {
316311
}
317312
}
318313

319-
ui(Mode::Pass, "tests/pass", &target, WithoutDependencies, tmpdir.path())?;
320-
ui(Mode::Pass, "tests/pass-dep", &target, WithDependencies, tmpdir.path())?;
321-
ui(Mode::Panic, "tests/panic", &target, WithDependencies, tmpdir.path())?;
322-
ui(Mode::Fail, "tests/fail", &target, WithoutDependencies, tmpdir.path())?;
323-
ui(Mode::Fail, "tests/fail-dep", &target, WithDependencies, tmpdir.path())?;
314+
ui(RunDepMode::Pass, "tests/pass", &target, WithoutDependencies, tmpdir.path())?;
315+
ui(RunDepMode::Pass, "tests/pass-dep", &target, WithDependencies, tmpdir.path())?;
316+
ui(RunDepMode::Panic, "tests/panic", &target, WithDependencies, tmpdir.path())?;
317+
ui(RunDepMode::Fail, "tests/fail", &target, WithoutDependencies, tmpdir.path())?;
318+
ui(RunDepMode::Fail, "tests/fail-dep", &target, WithDependencies, tmpdir.path())?;
324319
if cfg!(unix) {
325-
ui(Mode::Pass, "tests/native-lib/pass", &target, WithoutDependencies, tmpdir.path())?;
326-
ui(Mode::Fail, "tests/native-lib/fail", &target, WithoutDependencies, tmpdir.path())?;
320+
ui(RunDepMode::Pass, "tests/native-lib/pass", &target, WithoutDependencies, tmpdir.path())?;
321+
ui(RunDepMode::Fail, "tests/native-lib/fail", &target, WithoutDependencies, tmpdir.path())?;
327322
}
328323

329324
Ok(())
330325
}
331326

332327
fn run_dep_mode(target: String, args: impl Iterator<Item = OsString>) -> Result<()> {
333-
let mut config = miri_config(&target, "", Mode::Yolo, /* with dependencies */ true);
328+
let mut config = miri_config(&target, "", RunDepMode::Yolo, /* with dependencies */ true);
334329
config.comment_defaults.base().custom.remove("edition");
335330
config.fill_host_and_target()?;
336331
config.program.args = args.collect();

0 commit comments

Comments
 (0)