Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump ui_test #4155

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ windows-sys = { version = "0.52", features = [
] }

[dev-dependencies]
ui_test = "0.27.1"
colored = "2"
ui_test = "0.26.5"
rustc_version = "0.4"
regex = "1.5.5"
tempfile = "3"
Expand Down
42 changes: 28 additions & 14 deletions tests/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use ui_test::custom_flags::edition::Edition;
use ui_test::dependencies::DependencyBuilder;
use ui_test::per_test_config::TestConfig;
use ui_test::spanned::Spanned;
use ui_test::{CommandBuilder, Config, Format, Match, OutputConflictHandling, status_emitter};
use ui_test::{CommandBuilder, Config, Format, Match, ignore_output_conflict, status_emitter};

#[derive(Copy, Clone, Debug)]
enum Mode {
Expand Down Expand Up @@ -82,9 +82,18 @@ fn build_native_lib() -> PathBuf {
native_lib_path
}

struct WithDependencies {
bless: bool,
}

/// 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: Mode,
with_dependencies: Option<WithDependencies>,
) -> 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 Down Expand Up @@ -119,7 +128,7 @@ fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
// keep in sync with `./miri run`
config.comment_defaults.base().add_custom("edition", Edition("2021".into()));

if with_dependencies {
if let Some(WithDependencies { bless }) = with_dependencies {
config.comment_defaults.base().set_custom("dependencies", DependencyBuilder {
program: CommandBuilder {
// Set the `cargo-miri` binary, which we expect to be in the same folder as the `miri` binary.
Expand All @@ -134,6 +143,7 @@ fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
},
crate_manifest_path: Path::new("test_dependencies").join("Cargo.toml"),
build_std: None,
bless_lockfile: bless,
});
}
config
Expand All @@ -146,7 +156,20 @@ fn run_tests(
with_dependencies: bool,
tmpdir: &Path,
) -> Result<()> {
// Handle command-line arguments.
let mut args = ui_test::Args::test()?;
args.bless |= env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0");

let with_dependencies = with_dependencies.then_some(WithDependencies { bless: args.bless });

let mut config = miri_config(target, path, mode, with_dependencies);
config.with_args(&args);
config.bless_command = Some("./miri test --bless".into());

if env::var_os("MIRI_SKIP_UI_CHECKS").is_some() {
assert!(!args.bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time");
config.output_conflict_handling = ignore_output_conflict;
}

// Add a test env var to do environment communication tests.
config.program.envs.push(("MIRI_ENV_VAR_TEST".into(), Some("0".into())));
Expand Down Expand Up @@ -182,16 +205,6 @@ fn run_tests(
config.program.args.push(flag);
}

// Handle command-line arguments.
let mut args = ui_test::Args::test()?;
args.bless |= env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0");
config.with_args(&args);
config.bless_command = Some("./miri test --bless".into());

if env::var_os("MIRI_SKIP_UI_CHECKS").is_some() {
assert!(!args.bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time");
config.output_conflict_handling = OutputConflictHandling::Ignore;
}
eprintln!(" Compiler: {}", config.program.display());
ui_test::run_tests_generic(
// Only run one test suite. In the future we can add all test suites to one `Vec` and run
Expand Down Expand Up @@ -327,7 +340,8 @@ fn main() -> Result<()> {
}

fn run_dep_mode(target: String, args: impl Iterator<Item = OsString>) -> Result<()> {
let mut config = miri_config(&target, "", Mode::RunDep, /* with dependencies */ true);
let mut config =
miri_config(&target, "", Mode::RunDep, Some(WithDependencies { bless: false }));
config.comment_defaults.base().custom.remove("edition"); // `./miri` adds an `--edition` in `args`, so don't set it twice
config.fill_host_and_target()?;
config.program.args = args.collect();
Expand Down
Loading