Skip to content

Commit f5e6e03

Browse files
committed
bump ui_test to 0.22.2
1 parent 5881858 commit f5e6e03

File tree

3 files changed

+65
-30
lines changed

3 files changed

+65
-30
lines changed

Cargo.lock

Lines changed: 24 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ libloading = "0.8"
4444

4545
[dev-dependencies]
4646
colored = "2"
47-
ui_test = "0.21.1"
47+
ui_test = "0.22.2"
4848
rustc_version = "0.4"
4949
regex = "1.5.5"
5050
tempfile = "3"

tests/ui.rs

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::{env, process::Command};
77
use colored::*;
88
use regex::bytes::Regex;
99
use ui_test::color_eyre::eyre::{Context, Result};
10+
use ui_test::spanned::Spanned;
1011
use ui_test::{
1112
status_emitter, CommandBuilder, Config, Format, Match, Mode, OutputConflictHandling,
1213
RustfixMode,
@@ -63,23 +64,49 @@ fn build_native_lib() -> PathBuf {
6364
/// Does *not* set any args or env vars, since it is shared between the test runner and
6465
/// run_dep_mode.
6566
fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) -> Config {
67+
// FIXME: in ui_test 0.22.3+ this is method on Config.
68+
fn fill_host_and_target(cfg: &mut Config) {
69+
if cfg.host.is_none() {
70+
cfg.host = Some(get_host());
71+
}
72+
if cfg.target.is_none() {
73+
cfg.target = Some(cfg.host.clone().unwrap());
74+
}
75+
}
6676
// Miri is rustc-like, so we create a default builder for rustc and modify it
6777
let mut program = CommandBuilder::rustc();
6878
program.program = miri_path();
6979

7080
let mut config = Config {
7181
target: Some(target.to_owned()),
72-
stderr_filters: stderr_filters().into(),
73-
stdout_filters: stdout_filters().into(),
74-
mode,
7582
program,
7683
out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap()).join("ui"),
77-
edition: Some("2021".into()), // keep in sync with `./miri run`
7884
threads: std::env::var("MIRI_TEST_THREADS")
7985
.ok()
8086
.map(|threads| NonZero::new(threads.parse().unwrap()).unwrap()),
87+
output_conflict_handling: OutputConflictHandling::Error,
88+
bless_command: Some("./miri test --bless".into()),
8189
..Config::rustc(path)
8290
};
91+
fill_host_and_target(&mut config);
92+
93+
config.comment_defaults.base().normalize_stdout =
94+
stdout_filters().iter().cloned().map(|(m, v)| (m, v.into())).collect();
95+
config.comment_defaults.base().normalize_stderr =
96+
stderr_filters().iter().cloned().map(|(m, v)| (m, v.into())).collect();
97+
config.comment_defaults.base().mode = Spanned::dummy(mode).into();
98+
99+
// FIXME: this is replacement of removed ui_test feature for masking path with $DIR:
100+
// https://github.com/oli-obk/ui_test/pull/180
101+
// Can't use path_filter or other simpler filter because 'path' here is path to test suite,
102+
// not path to test, i.e. "tests/pass".
103+
// regex is oversimplified and can probably fail in corner cases.
104+
config.filter(path, "$$DIR");
105+
config.filter(r"\$DIR[\\/]([\w-]+[\\/])*", "$$DIR/");
106+
107+
// keep in sync with `./miri run`
108+
const EDITION: &str = "2021";
109+
config.comment_defaults.base().edition = Spanned::dummy(EDITION.to_owned()).into();
83110

84111
if with_dependencies {
85112
// Set the `cargo-miri` binary, which we expect to be in the same folder as the `miri` binary.
@@ -130,9 +157,11 @@ fn run_tests(
130157
}
131158
}
132159
config.program.args.push("-Zui-testing".into());
133-
config.program.args.push("--target".into());
134-
config.program.args.push(target.into());
135160

161+
if config.host != config.target {
162+
config.program.args.push("--target".into());
163+
config.program.args.push(target.into());
164+
}
136165
// If we're testing the native-lib functionality, then build the shared object file for testing
137166
// external C function calls and push the relevant compiler flag.
138167
if path.starts_with("tests/native-lib/") {
@@ -143,14 +172,12 @@ fn run_tests(
143172
}
144173

145174
// Handle command-line arguments.
146-
let args = ui_test::Args::test()?;
147-
let default_bless = env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0");
148-
config.with_args(&args, default_bless);
149-
if let OutputConflictHandling::Error(msg) = &mut config.output_conflict_handling {
150-
*msg = "./miri test --bless".into();
151-
}
175+
let mut args = ui_test::Args::test()?;
176+
args.bless |= env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0");
177+
config.with_args(&args);
178+
152179
if env::var_os("MIRI_SKIP_UI_CHECKS").is_some() {
153-
assert!(!default_bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time");
180+
assert!(!args.bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time");
154181
config.output_conflict_handling = OutputConflictHandling::Ignore;
155182
}
156183
eprintln!(" Compiler: {}", config.program.display());

0 commit comments

Comments
 (0)