Skip to content

Commit 732f127

Browse files
committed
Update ui test crate
1 parent 878c6ae commit 732f127

File tree

3 files changed

+36
-72
lines changed

3 files changed

+36
-72
lines changed

src/tools/miri/Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,9 +842,9 @@ dependencies = [
842842

843843
[[package]]
844844
name = "ui_test"
845-
version = "0.10.0"
845+
version = "0.11.0"
846846
source = "registry+https://github.com/rust-lang/crates.io-index"
847-
checksum = "191a442639ea102fa62671026047e51d574bfda44b7fdf32151d7314624c1cd2"
847+
checksum = "b75049e51d3db204b2de79c8ff7a8675c628d81ceef6ec97598c1ab7d4d66802"
848848
dependencies = [
849849
"bstr",
850850
"cargo-platform",

src/tools/miri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ libloading = "0.7"
3636

3737
[dev-dependencies]
3838
colored = "2"
39-
ui_test = "0.10"
39+
ui_test = "0.11"
4040
rustc_version = "0.4"
4141
# Features chosen to match those required by env_logger, to avoid rebuilds
4242
regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] }

src/tools/miri/tests/compiletest.rs

Lines changed: 33 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use regex::bytes::Regex;
33
use std::ffi::OsString;
44
use std::path::{Path, PathBuf};
55
use std::{env, process::Command};
6-
use ui_test::status_emitter::StatusEmitter;
76
use ui_test::CommandBuilder;
87
use ui_test::{color_eyre::Result, Config, Match, Mode, OutputConflictHandling};
98

@@ -76,7 +75,7 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
7675
let skip_ui_checks = env::var_os("MIRI_SKIP_UI_CHECKS").is_some();
7776

7877
let output_conflict_handling = match (env::var_os("MIRI_BLESS").is_some(), skip_ui_checks) {
79-
(false, false) => OutputConflictHandling::Error,
78+
(false, false) => OutputConflictHandling::Error("./miri bless".into()),
8079
(true, false) => OutputConflictHandling::Bless,
8180
(false, true) => OutputConflictHandling::Ignore,
8281
(true, true) => panic!("cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time"),
@@ -86,13 +85,11 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
8685
target: Some(target.to_owned()),
8786
stderr_filters: STDERR.clone(),
8887
stdout_filters: STDOUT.clone(),
89-
root_dir: PathBuf::from(path),
9088
mode,
9189
program,
9290
output_conflict_handling,
93-
quiet: false,
9491
edition: Some("2021".into()),
95-
..Config::default()
92+
..Config::rustc(path.into())
9693
};
9794

9895
let use_std = env::var_os("MIRI_NO_STD").is_none();
@@ -113,39 +110,48 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
113110
}
114111

115112
fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> Result<()> {
116-
let mut config = test_config(target, path, mode, with_dependencies);
113+
let config = test_config(target, path, mode, with_dependencies);
117114

118115
// Handle command-line arguments.
119116
let mut after_dashdash = false;
120-
config.path_filter.extend(std::env::args().skip(1).filter(|arg| {
121-
if after_dashdash {
122-
// Just propagate everything.
123-
return true;
124-
}
125-
match &**arg {
126-
"--quiet" => {
127-
config.quiet = true;
128-
false
129-
}
130-
"--" => {
131-
after_dashdash = true;
132-
false
117+
let mut quiet = false;
118+
let filters = std::env::args()
119+
.skip(1)
120+
.filter(|arg| {
121+
if after_dashdash {
122+
// Just propagate everything.
123+
return true;
133124
}
134-
s if s.starts_with('-') => {
135-
panic!("unknown compiletest flag `{s}`");
125+
match &**arg {
126+
"--quiet" => {
127+
quiet = true;
128+
false
129+
}
130+
"--" => {
131+
after_dashdash = true;
132+
false
133+
}
134+
s if s.starts_with('-') => {
135+
panic!("unknown compiletest flag `{s}`");
136+
}
137+
_ => true,
136138
}
137-
_ => true,
138-
}
139-
}));
140-
139+
})
140+
.collect::<Vec<_>>();
141141
eprintln!(" Compiler: {}", config.program.display());
142142
ui_test::run_tests_generic(
143143
config,
144144
// The files we're actually interested in (all `.rs` files).
145-
|path| path.extension().is_some_and(|ext| ext == "rs"),
145+
|path| {
146+
path.extension().is_some_and(|ext| ext == "rs")
147+
&& (filters.is_empty() || filters.iter().any(|f| path.starts_with(f)))
148+
},
146149
// This could be used to overwrite the `Config` on a per-test basis.
147150
|_, _| None,
148-
TextAndGha,
151+
(
152+
ui_test::status_emitter::Text,
153+
ui_test::status_emitter::Gha::<false> { name: format!("{mode:?} {path} ({target})") },
154+
),
149155
)
150156
}
151157

@@ -270,45 +276,3 @@ fn run_dep_mode(target: String, mut args: impl Iterator<Item = OsString>) -> Res
270276
cmd.args(args);
271277
if cmd.spawn()?.wait()?.success() { Ok(()) } else { std::process::exit(1) }
272278
}
273-
274-
/// This is a custom renderer for `ui_test` output that does not emit github actions
275-
/// `group`s, while still producing regular github actions messages on test failures.
276-
struct TextAndGha;
277-
impl StatusEmitter for TextAndGha {
278-
fn failed_test<'a>(
279-
&'a self,
280-
revision: &'a str,
281-
path: &'a Path,
282-
cmd: &'a Command,
283-
stderr: &'a [u8],
284-
) -> Box<dyn std::fmt::Debug + 'a> {
285-
Box::new((
286-
ui_test::status_emitter::Gha::<false>.failed_test(revision, path, cmd, stderr),
287-
ui_test::status_emitter::Text.failed_test(revision, path, cmd, stderr),
288-
))
289-
}
290-
291-
fn run_tests(&self, _config: &Config) -> Box<dyn ui_test::status_emitter::DuringTestRun> {
292-
Box::new(TextAndGha)
293-
}
294-
295-
fn finalize(
296-
&self,
297-
failures: usize,
298-
succeeded: usize,
299-
ignored: usize,
300-
filtered: usize,
301-
) -> Box<dyn ui_test::status_emitter::Summary> {
302-
Box::new((
303-
ui_test::status_emitter::Gha::<false>.finalize(failures, succeeded, ignored, filtered),
304-
ui_test::status_emitter::Text.finalize(failures, succeeded, ignored, filtered),
305-
))
306-
}
307-
}
308-
309-
impl ui_test::status_emitter::DuringTestRun for TextAndGha {
310-
fn test_result(&mut self, path: &Path, revision: &str, result: &ui_test::TestResult) {
311-
ui_test::status_emitter::Text.test_result(path, revision, result);
312-
ui_test::status_emitter::Gha::<false>.test_result(path, revision, result);
313-
}
314-
}

0 commit comments

Comments
 (0)