Skip to content

Commit

Permalink
Rename Mode to RunDepMode
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Sep 11, 2024
1 parent 008326d commit c44aaff
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions tests/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ui_test::spanned::Spanned;
use ui_test::{status_emitter, CommandBuilder, Config, Format, Match, OutputConflictHandling};

#[derive(Copy, Clone, Debug)]
enum Mode {
enum RunDepMode {
Pass,
Fail,
Yolo,
Expand Down Expand Up @@ -80,7 +80,7 @@ fn build_native_lib() -> PathBuf {

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

config.comment_defaults.base().exit_status = match mode {
Mode::Pass => Some(0_i32),
Mode::Fail => Some(1),
Mode::Yolo => None,
Mode::Panic => Some(101),
RunDepMode::Pass => Some(0_i32),
RunDepMode::Fail => Some(1),
RunDepMode::Yolo => None,
RunDepMode::Panic => Some(101),
}
.map(Spanned::dummy)
.into();

config.comment_defaults.base().require_annotations = Spanned::dummy(match mode {
Mode::Pass => false,
Mode::Fail => true,
Mode::Yolo => false,
Mode::Panic => false,
})
config.comment_defaults.base().require_annotations = Spanned::dummy(matches!(mode, RunDepMode::Fail))
.into();

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

fn run_tests(
mode: Mode,
mode: RunDepMode,
path: &str,
target: &str,
with_dependencies: bool,
Expand Down Expand Up @@ -280,7 +275,7 @@ enum Dependencies {
use Dependencies::*;

fn ui(
mode: Mode,
mode: RunDepMode,
path: &str,
target: &str,
with_dependencies: Dependencies,
Expand Down Expand Up @@ -316,21 +311,21 @@ fn main() -> Result<()> {
}
}

ui(Mode::Pass, "tests/pass", &target, WithoutDependencies, tmpdir.path())?;
ui(Mode::Pass, "tests/pass-dep", &target, WithDependencies, tmpdir.path())?;
ui(Mode::Panic, "tests/panic", &target, WithDependencies, tmpdir.path())?;
ui(Mode::Fail, "tests/fail", &target, WithoutDependencies, tmpdir.path())?;
ui(Mode::Fail, "tests/fail-dep", &target, WithDependencies, tmpdir.path())?;
ui(RunDepMode::Pass, "tests/pass", &target, WithoutDependencies, tmpdir.path())?;
ui(RunDepMode::Pass, "tests/pass-dep", &target, WithDependencies, tmpdir.path())?;
ui(RunDepMode::Panic, "tests/panic", &target, WithDependencies, tmpdir.path())?;
ui(RunDepMode::Fail, "tests/fail", &target, WithoutDependencies, tmpdir.path())?;
ui(RunDepMode::Fail, "tests/fail-dep", &target, WithDependencies, tmpdir.path())?;
if cfg!(unix) {
ui(Mode::Pass, "tests/native-lib/pass", &target, WithoutDependencies, tmpdir.path())?;
ui(Mode::Fail, "tests/native-lib/fail", &target, WithoutDependencies, tmpdir.path())?;
ui(RunDepMode::Pass, "tests/native-lib/pass", &target, WithoutDependencies, tmpdir.path())?;
ui(RunDepMode::Fail, "tests/native-lib/fail", &target, WithoutDependencies, tmpdir.path())?;
}

Ok(())
}

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

0 comments on commit c44aaff

Please sign in to comment.