Skip to content

Commit c004fc1

Browse files
committed
Auto merge of #3008 - oli-obk:ui_test_progress_bars, r=RalfJung
bump ui test crate The recommended way to run tests locally is `./miri bless -- -- --quiet`, which will show * progress bars * the currently running tests (allowing you to see which ones are still running towards the end of the test suite) * the output of the currently running tests (if they are slow). This means slow running tests can output lines to `stderr` and the last line will be shown after the test name and updated every few hundred milliseconds. As a side effect this PR also fixes #2998 and only builds dependencies if any tests actually need them (this means that with the next ui_test update we'll be able to merge all our test suites). Also fixes #3052.
2 parents 15d1ac5 + 4a3b941 commit c004fc1

File tree

102 files changed

+165
-64
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+165
-64
lines changed

Diff for: Cargo.lock

+114-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+1-1
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.11.7"
39+
ui_test = "0.21.1"
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"] }

Diff for: README.md

+2

Diff for: tests/compiletest.rs

+46-55
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use colored::*;
22
use regex::bytes::Regex;
33
use std::ffi::OsString;
4+
use std::num::NonZeroUsize;
45
use std::path::{Path, PathBuf};
56
use std::{env, process::Command};
67
use ui_test::{color_eyre::Result, Config, Match, Mode, OutputConflictHandling};
7-
use ui_test::{status_emitter, CommandBuilder};
8+
use ui_test::{status_emitter, CommandBuilder, Format, RustfixMode};
89

910
fn miri_path() -> PathBuf {
1011
PathBuf::from(option_env!("MIRI").unwrap_or(env!("CARGO_BIN_EXE_miri")))
@@ -78,26 +79,18 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
7879
program.args.push(flag);
7980
}
8081

81-
let bless = env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0");
82-
let skip_ui_checks = env::var_os("MIRI_SKIP_UI_CHECKS").is_some();
83-
84-
let output_conflict_handling = match (bless, skip_ui_checks) {
85-
(false, false) => OutputConflictHandling::Error("./miri test --bless".into()),
86-
(true, false) => OutputConflictHandling::Bless,
87-
(false, true) => OutputConflictHandling::Ignore,
88-
(true, true) => panic!("cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time"),
89-
};
90-
9182
let mut config = Config {
9283
target: Some(target.to_owned()),
9384
stderr_filters: STDERR.clone(),
9485
stdout_filters: STDOUT.clone(),
9586
mode,
9687
program,
97-
output_conflict_handling,
9888
out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap()).join("ui"),
9989
edition: Some("2021".into()),
100-
..Config::rustc(path.into())
90+
threads: std::env::var("MIRI_TEST_THREADS")
91+
.ok()
92+
.map(|threads| NonZeroUsize::new(threads.parse().unwrap()).unwrap()),
93+
..Config::rustc(path)
10194
};
10295

10396
let use_std = env::var_os("MIRI_NO_STD").is_none();
@@ -120,51 +113,32 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
120113
}
121114

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

125118
// Handle command-line arguments.
126-
let mut after_dashdash = false;
127-
let mut quiet = false;
128-
let filters = std::env::args()
129-
.skip(1)
130-
.filter(|arg| {
131-
if after_dashdash {
132-
// Just propagate everything.
133-
return true;
134-
}
135-
match &**arg {
136-
"--quiet" => {
137-
quiet = true;
138-
false
139-
}
140-
"--" => {
141-
after_dashdash = true;
142-
false
143-
}
144-
s if s.starts_with('-') => {
145-
panic!("unknown compiletest flag `{s}`");
146-
}
147-
_ => true,
148-
}
149-
})
150-
.collect::<Vec<_>>();
119+
let args = ui_test::Args::test()?;
120+
let default_bless = env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0");
121+
config.with_args(&args, default_bless);
122+
if let OutputConflictHandling::Error(msg) = &mut config.output_conflict_handling {
123+
*msg = "./miri test --bless".into();
124+
}
125+
if env::var_os("MIRI_SKIP_UI_CHECKS").is_some() {
126+
assert!(!default_bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time");
127+
config.output_conflict_handling = OutputConflictHandling::Ignore;
128+
}
151129
eprintln!(" Compiler: {}", config.program.display());
152130
ui_test::run_tests_generic(
153-
config,
131+
// Only run one test suite. In the future we can add all test suites to one `Vec` and run
132+
// them all at once, making best use of systems with high parallelism.
133+
vec![config],
154134
// The files we're actually interested in (all `.rs` files).
155-
|path| {
156-
path.extension().is_some_and(|ext| ext == "rs")
157-
&& (filters.is_empty()
158-
|| filters.iter().any(|f| path.display().to_string().contains(f)))
159-
},
135+
ui_test::default_file_filter,
160136
// This could be used to overwrite the `Config` on a per-test basis.
161-
|_, _| None,
137+
|_, _, _| {},
162138
(
163-
if quiet {
164-
Box::<status_emitter::Quiet>::default()
165-
as Box<dyn status_emitter::StatusEmitter + Send>
166-
} else {
167-
Box::new(status_emitter::Text)
139+
match args.format {
140+
Format::Terse => status_emitter::Text::quiet(),
141+
Format::Pretty => status_emitter::Text::verbose(),
168142
},
169143
status_emitter::Gha::</* GHA Actions groups*/ false> {
170144
name: format!("{mode:?} {path} ({target})"),
@@ -269,11 +243,22 @@ fn main() -> Result<()> {
269243
ui(Mode::Pass, "tests/pass", &target, WithoutDependencies)?;
270244
ui(Mode::Pass, "tests/pass-dep", &target, WithDependencies)?;
271245
ui(Mode::Panic, "tests/panic", &target, WithDependencies)?;
272-
ui(Mode::Fail { require_patterns: true }, "tests/fail", &target, WithDependencies)?;
246+
ui(
247+
Mode::Fail { require_patterns: true, rustfix: RustfixMode::Disabled },
248+
"tests/fail",
249+
&target,
250+
WithoutDependencies,
251+
)?;
252+
ui(
253+
Mode::Fail { require_patterns: true, rustfix: RustfixMode::Disabled },
254+
"tests/fail-dep",
255+
&target,
256+
WithDependencies,
257+
)?;
273258
if cfg!(target_os = "linux") {
274259
ui(Mode::Pass, "tests/extern-so/pass", &target, WithoutDependencies)?;
275260
ui(
276-
Mode::Fail { require_patterns: true },
261+
Mode::Fail { require_patterns: true, rustfix: RustfixMode::Disabled },
277262
"tests/extern-so/fail",
278263
&target,
279264
WithoutDependencies,
@@ -285,11 +270,17 @@ fn main() -> Result<()> {
285270

286271
fn run_dep_mode(target: String, mut args: impl Iterator<Item = OsString>) -> Result<()> {
287272
let path = args.next().expect("./miri run-dep must be followed by a file name");
288-
let mut config = test_config(&target, "", Mode::Yolo, /* with dependencies */ true);
273+
let mut config = test_config(
274+
&target,
275+
"",
276+
Mode::Yolo { rustfix: RustfixMode::Disabled },
277+
/* with dependencies */ true,
278+
);
289279
config.program.args.clear(); // We want to give the user full control over flags
290-
config.build_dependencies_and_link_them()?;
280+
let dep_args = config.build_dependencies()?;
291281

292282
let mut cmd = config.program.build(&config.out_dir);
283+
cmd.args(dep_args);
293284

294285
cmd.arg(path);
295286

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: tests/pass/backtrace/backtrace-api-v0.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$DIR/backtrace-api-v0.rs:24:14 (func_d)
22
$DIR/backtrace-api-v0.rs:20:5 (func_c)
3-
$DIR/backtrace-api-v0.rs:9:5 (func_b)
3+
$DIR/backtrace-api-v0.rs:9:5 (func_b::<u8>)
44
$DIR/backtrace-api-v0.rs:5:5 (func_a)
55
$DIR/backtrace-api-v0.rs:29:18 (main)

0 commit comments

Comments
 (0)