Merge pull request #4155 from oli-obk/push-sloyuvlsvqxn

Bump ui_test
This commit is contained in:
Ralf Jung 2025-01-27 11:35:29 +00:00 committed by GitHub
commit 396691abc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 17 deletions

View file

@ -1051,9 +1051,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "ui_test"
version = "0.26.5"
version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32ee4c40e5a5f9fa6864ff976473e5d6a6e9884b6ce68b40690d9f87e1994c83"
checksum = "180a1250feba0214b892e22c3a14e9f6688cc084d7b45ec4672106fcb7914641"
dependencies = [
"annotate-snippets",
"anyhow",

View file

@ -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"

View file

@ -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 {
@ -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();
@ -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.
@ -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
@ -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())));
@ -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
@ -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();