Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 84f80f1

Browse files
committed
Auto merge of rust-lang#2884 - oli-obk:ui_test, r=RalfJung,oli-obk
Update to latest ui_test crate version. Also stops using github actions groups that conflict with our groups as github does not nest them
2 parents a477b81 + f321c8d commit 84f80f1

40 files changed

+118
-64
lines changed

src/tools/miri/Cargo.lock

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

821821
[[package]]
822822
name = "ui_test"
823-
version = "0.6.2"
823+
version = "0.9.0"
824824
source = "registry+https://github.com/rust-lang/crates.io-index"
825-
checksum = "3e10f5f88ce8c331a388deda1e6e2bd533c73ca89cc5f539a3df02ed35c8efba"
825+
checksum = "95033b0e41b8018013d99a6f1486c1ae5bd080378ced60c5f797e93842423b33"
826826
dependencies = [
827827
"bstr",
828828
"cargo-platform",

src/tools/miri/Cargo.toml

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

4040
[dev-dependencies]
4141
colored = "2"
42-
ui_test = "0.6.2"
42+
ui_test = "0.9"
4343
rustc_version = "0.4"
4444
# Features chosen to match those required by env_logger, to avoid rebuilds
4545
regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] }

src/tools/miri/tests/compiletest.rs

Lines changed: 78 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use colored::*;
22
use regex::bytes::Regex;
33
use std::path::{Path, PathBuf};
44
use std::{env, process::Command};
5+
use ui_test::status_emitter::StatusEmitter;
6+
use ui_test::CommandBuilder;
57
use ui_test::{color_eyre::Result, Config, Match, Mode, OutputConflictHandling};
68

79
fn miri_path() -> PathBuf {
@@ -44,40 +46,30 @@ fn build_so_for_c_ffi_tests() -> PathBuf {
4446
}
4547

4648
fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> Result<()> {
47-
let mut config = Config {
48-
target: Some(target.to_owned()),
49-
stderr_filters: STDERR.clone(),
50-
stdout_filters: STDOUT.clone(),
51-
root_dir: PathBuf::from(path),
52-
mode,
53-
program: miri_path(),
54-
quiet: false,
55-
edition: Some("2021".into()),
56-
..Config::default()
57-
};
49+
// Miri is rustc-like, so we create a default builder for rustc and modify it
50+
let mut program = CommandBuilder::rustc();
51+
program.program = miri_path();
5852

5953
let in_rustc_test_suite = option_env!("RUSTC_STAGE").is_some();
6054

6155
// Add some flags we always want.
6256
if in_rustc_test_suite {
6357
// Less aggressive warnings to make the rustc toolstate management less painful.
6458
// (We often get warnings when e.g. a feature gets stabilized or some lint gets added/improved.)
65-
config.args.push("-Astable-features".into());
66-
config.args.push("-Aunused".into());
59+
program.args.push("-Astable-features".into());
60+
program.args.push("-Aunused".into());
6761
} else {
68-
config.args.push("-Dwarnings".into());
69-
config.args.push("-Dunused".into());
62+
program.args.push("-Dwarnings".into());
63+
program.args.push("-Dunused".into());
7064
}
7165
if let Ok(extra_flags) = env::var("MIRIFLAGS") {
7266
for flag in extra_flags.split_whitespace() {
73-
config.args.push(flag.into());
67+
program.args.push(flag.into());
7468
}
7569
}
76-
config.args.push("-Zui-testing".into());
77-
if let Some(target) = &config.target {
78-
config.args.push("--target".into());
79-
config.args.push(target.into());
80-
}
70+
program.args.push("-Zui-testing".into());
71+
program.args.push("--target".into());
72+
program.args.push(target.into());
8173

8274
// If we're on linux, and we're testing the extern-so functionality,
8375
// then build the shared object file for testing external C function calls
@@ -86,18 +78,31 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R
8678
let so_file_path = build_so_for_c_ffi_tests();
8779
let mut flag = std::ffi::OsString::from("-Zmiri-extern-so-file=");
8880
flag.push(so_file_path.into_os_string());
89-
config.args.push(flag);
81+
program.args.push(flag);
9082
}
9183

9284
let skip_ui_checks = env::var_os("MIRI_SKIP_UI_CHECKS").is_some();
9385

94-
config.output_conflict_handling = match (env::var_os("MIRI_BLESS").is_some(), skip_ui_checks) {
86+
let output_conflict_handling = match (env::var_os("MIRI_BLESS").is_some(), skip_ui_checks) {
9587
(false, false) => OutputConflictHandling::Error,
9688
(true, false) => OutputConflictHandling::Bless,
9789
(false, true) => OutputConflictHandling::Ignore,
9890
(true, true) => panic!("cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time"),
9991
};
10092

93+
let mut config = Config {
94+
target: Some(target.to_owned()),
95+
stderr_filters: STDERR.clone(),
96+
stdout_filters: STDOUT.clone(),
97+
root_dir: PathBuf::from(path),
98+
mode,
99+
program,
100+
output_conflict_handling,
101+
quiet: false,
102+
edition: Some("2021".into()),
103+
..Config::default()
104+
};
105+
101106
// Handle command-line arguments.
102107
let mut after_dashdash = false;
103108
config.path_filter.extend(std::env::args().skip(1).filter(|arg| {
@@ -135,7 +140,14 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R
135140
"run".into(), // There is no `cargo miri build` so we just use `cargo miri run`.
136141
];
137142
}
138-
ui_test::run_tests(config)
143+
ui_test::run_tests_generic(
144+
config,
145+
// The files we're actually interested in (all `.rs` files).
146+
|path| path.extension().is_some_and(|ext| ext == "rs"),
147+
// This could be used to overwrite the `Config` on a per-test basis.
148+
|_, _| None,
149+
TextAndGha,
150+
)
139151
}
140152

141153
macro_rules! regexes {
@@ -235,3 +247,45 @@ fn main() -> Result<()> {
235247

236248
Ok(())
237249
}
250+
251+
/// This is a custom renderer for `ui_test` output that does not emit github actions
252+
/// `group`s, while still producing regular github actions messages on test failures.
253+
struct TextAndGha;
254+
impl StatusEmitter for TextAndGha {
255+
fn failed_test<'a>(
256+
&'a self,
257+
revision: &'a str,
258+
path: &'a Path,
259+
cmd: &'a Command,
260+
stderr: &'a [u8],
261+
) -> Box<dyn std::fmt::Debug + 'a> {
262+
Box::new((
263+
ui_test::status_emitter::Gha::<false>.failed_test(revision, path, cmd, stderr),
264+
ui_test::status_emitter::Text.failed_test(revision, path, cmd, stderr),
265+
))
266+
}
267+
268+
fn run_tests(&self, _config: &Config) -> Box<dyn ui_test::status_emitter::DuringTestRun> {
269+
Box::new(TextAndGha)
270+
}
271+
272+
fn finalize(
273+
&self,
274+
failures: usize,
275+
succeeded: usize,
276+
ignored: usize,
277+
filtered: usize,
278+
) -> Box<dyn ui_test::status_emitter::Summary> {
279+
Box::new((
280+
ui_test::status_emitter::Gha::<false>.finalize(failures, succeeded, ignored, filtered),
281+
ui_test::status_emitter::Text.finalize(failures, succeeded, ignored, filtered),
282+
))
283+
}
284+
}
285+
286+
impl ui_test::status_emitter::DuringTestRun for TextAndGha {
287+
fn test_result(&mut self, path: &Path, revision: &str, result: &ui_test::TestResult) {
288+
ui_test::status_emitter::Text.test_result(path, revision, result);
289+
ui_test::status_emitter::Gha::<false>.test_result(path, revision, result);
290+
}
291+
}

src/tools/miri/tests/fail/alloc/deallocate-bad-alignment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::alloc::{alloc, dealloc, Layout};
22

3-
//@error-pattern: has size 1 and alignment 1, but gave size 1 and alignment 2
3+
//@error-in-other-file: has size 1 and alignment 1, but gave size 1 and alignment 2
44

55
fn main() {
66
unsafe {

src/tools/miri/tests/fail/alloc/deallocate-bad-size.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::alloc::{alloc, dealloc, Layout};
22

3-
//@error-pattern: has size 1 and alignment 1, but gave size 2 and alignment 1
3+
//@error-in-other-file: has size 1 and alignment 1, but gave size 2 and alignment 1
44

55
fn main() {
66
unsafe {

src/tools/miri/tests/fail/alloc/deallocate-twice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::alloc::{alloc, dealloc, Layout};
22

3-
//@error-pattern: dereferenced after this allocation got freed
3+
//@error-in-other-file: dereferenced after this allocation got freed
44

55
fn main() {
66
unsafe {

src/tools/miri/tests/fail/alloc/global_system_mixup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Make sure we detect when the `Global` and `System` allocators are mixed
22
// (even when the default `Global` uses `System`).
3-
//@error-pattern: /deallocating .*, which is Rust heap memory, using .* heap deallocation operation/
3+
//@error-in-other-file: /deallocating .*, which is Rust heap memory, using .* heap deallocation operation/
44

55
//@normalize-stderr-test: "using [A-Za-z]+ heap deallocation operation" -> "using PLATFORM heap deallocation operation"
66
//@normalize-stderr-test: "\| +\^+" -> "| ^"

src/tools/miri/tests/fail/alloc/reallocate-bad-size.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::alloc::{alloc, realloc, Layout};
22

3-
//@error-pattern: has size 1 and alignment 1, but gave size 2 and alignment 1
3+
//@error-in-other-file: has size 1 and alignment 1, but gave size 2 and alignment 1
44

55
fn main() {
66
unsafe {

src/tools/miri/tests/fail/alloc/reallocate-dangling.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::alloc::{alloc, dealloc, realloc, Layout};
22

3-
//@error-pattern: dereferenced after this allocation got freed
3+
//@error-in-other-file: dereferenced after this allocation got freed
44

55
fn main() {
66
unsafe {

src/tools/miri/tests/fail/alloc/stack_free.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Validation/SB changes why we fail
22
//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
33

4-
//@error-pattern: /deallocating .*, which is stack variable memory, using Rust heap deallocation operation/
4+
//@error-in-other-file: /deallocating .*, which is stack variable memory, using Rust heap deallocation operation/
55

66
fn main() {
77
let x = 42;

src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ignore-target-windows: No libc on Windows
2-
//@error-pattern: the main thread terminated without waiting for all remaining threads
2+
//@error-in-other-file: the main thread terminated without waiting for all remaining threads
33

44
// Check that we terminate the program when the main thread terminates.
55

src/tools/miri/tests/fail/concurrency/windows_join_detached.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@only-target-windows: Uses win32 api functions
2-
//@error-pattern: Undefined Behavior: trying to join a detached thread
2+
//@error-in-other-file: Undefined Behavior: trying to join a detached thread
33

44
// Joining a detached thread is undefined behavior.
55

src/tools/miri/tests/fail/deny_lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: miri cannot be run on programs that fail compilation
1+
//@error-in-other-file: miri cannot be run on programs that fail compilation
22

33
#![deny(warnings)]
44

src/tools/miri/tests/fail/intrinsics/simd-float-to-int.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: cannot be represented in target type `i32`
1+
//@error-in-other-file: cannot be represented in target type `i32`
22
#![feature(portable_simd)]
33
use std::simd::*;
44

src/tools/miri/tests/fail/intrinsics/simd-gather.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: pointer to 1 byte starting at offset 9 is out-of-bounds
1+
//@error-in-other-file: pointer to 1 byte starting at offset 9 is out-of-bounds
22
#![feature(portable_simd)]
33
use std::simd::*;
44

src/tools/miri/tests/fail/intrinsics/simd-scatter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: pointer to 1 byte starting at offset 9 is out-of-bounds
1+
//@error-in-other-file: pointer to 1 byte starting at offset 9 is out-of-bounds
22
#![feature(portable_simd)]
33
use std::simd::*;
44

src/tools/miri/tests/fail/layout_cycle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: a cycle occurred during layout computation
1+
//@error-in-other-file: a cycle occurred during layout computation
22
//~^ ERROR: cycle detected when computing layout of
33

44
use std::mem;

src/tools/miri/tests/fail/memleak.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: memory leaked
1+
//@error-in-other-file: memory leaked
22
//@normalize-stderr-test: ".*│.*" -> "$$stripped$$"
33

44
fn main() {

src/tools/miri/tests/fail/memleak_no_backtrace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@compile-flags: -Zmiri-disable-leak-backtraces
2-
//@error-pattern: the evaluated program leaked memory
2+
//@error-in-other-file: the evaluated program leaked memory
33
//@normalize-stderr-test: ".*│.*" -> "$$stripped$$"
44

55
fn main() {

src/tools/miri/tests/fail/memleak_rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: memory leaked
1+
//@error-in-other-file: memory leaked
22
//@stderr-per-bitwidth
33
//@normalize-stderr-test: ".*│.*" -> "$$stripped$$"
44

src/tools/miri/tests/fail/no_main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
//@error-pattern: miri can only run programs that have a main function
1+
//@error-in-other-file: miri can only run programs that have a main function
22
#![no_main]

src/tools/miri/tests/fail/panic/double_panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: the program aborted
1+
//@error-in-other-file: the program aborted
22
//@normalize-stderr-test: "\| +\^+" -> "| ^"
33
//@normalize-stderr-test: "unsafe \{ libc::abort\(\) \}|crate::intrinsics::abort\(\);" -> "ABORT();"
44
//@normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> "$1"

src/tools/miri/tests/fail/panic/panic_abort1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: the program aborted execution
1+
//@error-in-other-file: the program aborted execution
22
//@normalize-stderr-test: "\| +\^+" -> "| ^"
33
//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();"
44
//@compile-flags: -C panic=abort

src/tools/miri/tests/fail/panic/panic_abort2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: the program aborted execution
1+
//@error-in-other-file: the program aborted execution
22
//@normalize-stderr-test: "\| +\^+" -> "| ^"
33
//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();"
44
//@compile-flags: -C panic=abort

src/tools/miri/tests/fail/panic/panic_abort3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: the program aborted execution
1+
//@error-in-other-file: the program aborted execution
22
//@normalize-stderr-test: "\| +\^+" -> "| ^"
33
//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();"
44
//@compile-flags: -C panic=abort

src/tools/miri/tests/fail/panic/panic_abort4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: the program aborted execution
1+
//@error-in-other-file: the program aborted execution
22
//@normalize-stderr-test: "\| +\^+" -> "| ^"
33
//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();"
44
//@compile-flags: -C panic=abort

src/tools/miri/tests/fail/shims/fs/isolated_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ignore-target-windows: File handling is not implemented yet
2-
//@error-pattern: `open` not available when isolation is enabled
2+
//@error-in-other-file: `open` not available when isolation is enabled
33

44
fn main() {
55
let _file = std::fs::File::open("file.txt").unwrap();

src/tools/miri/tests/fail/stacked_borrows/deallocate_against_protector1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: /deallocating while item \[Unique for .*\] is strongly protected/
1+
//@error-in-other-file: /deallocating while item \[Unique for .*\] is strongly protected/
22

33
fn inner(x: &mut i32, f: fn(&mut i32)) {
44
// `f` may mutate, but it may not deallocate!

src/tools/miri/tests/fail/stacked_borrows/drop_in_place_retag.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Test that drop_in_place mutably retags the entire place, even for a type that does not need
22
//! dropping, ensuring among other things that it is writeable
33
4-
//@error-pattern: /retag .* for Unique permission .* only grants SharedReadOnly permission/
4+
//@error-in-other-file: /retag .* for Unique permission .* only grants SharedReadOnly permission/
55

66
fn main() {
77
unsafe {

src/tools/miri/tests/fail/stacked_borrows/illegal_dealloc1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: /deallocation .* tag does not exist in the borrow stack/
1+
//@error-in-other-file: /deallocation .* tag does not exist in the borrow stack/
22
use std::alloc::{alloc, dealloc, Layout};
33

44
fn main() {

src/tools/miri/tests/fail/stacked_borrows/issue-miri-1050-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: pointer to 4 bytes starting at offset 0 is out-of-bounds
1+
//@error-in-other-file: pointer to 4 bytes starting at offset 0 is out-of-bounds
22

33
fn main() {
44
unsafe {

src/tools/miri/tests/fail/stacked_borrows/issue-miri-1050-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: is a dangling pointer
1+
//@error-in-other-file: is a dangling pointer
22
use std::ptr::NonNull;
33

44
fn main() {

src/tools/miri/tests/fail/stacked_borrows/newtype_pair_retagging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: which is strongly protected
1+
//@error-in-other-file: which is strongly protected
22
struct Newtype<'a>(&'a mut i32, i32);
33

44
fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {

src/tools/miri/tests/fail/stacked_borrows/newtype_retagging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@error-pattern: which is strongly protected
1+
//@error-in-other-file: which is strongly protected
22
struct Newtype<'a>(&'a mut i32);
33

44
fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {

src/tools/miri/tests/fail/stacked_borrows/zst_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@compile-flags: -Zmiri-strict-provenance
2-
//@error-pattern: /retag .* tag does not exist in the borrow stack/
2+
//@error-in-other-file: /retag .* tag does not exist in the borrow stack/
33

44
fn main() {
55
unsafe {

src/tools/miri/tests/fail/tokio/sleep.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@compile-flags: -Zmiri-permissive-provenance -Zmiri-backtrace=full
22
//@only-target-x86_64-unknown-linux: support for tokio only on linux and x86
3-
//@error-pattern: returning ready events from epoll_wait is not yet implemented
3+
//@error-in-other-file: returning ready events from epoll_wait is not yet implemented
44
//@normalize-stderr-test: " += note:.*\n" -> ""
55

66
use tokio::time::{sleep, Duration, Instant};

0 commit comments

Comments
 (0)