Skip to content

Commit b4dc4f3

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 rust-lang/miri#3052.
2 parents efd04b6 + 71aea48 commit b4dc4f3

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

src/tools/miri/Cargo.lock

Lines changed: 114 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ dependencies = [
2626
"memchr",
2727
]
2828

29+
[[package]]
30+
name = "annotate-snippets"
31+
version = "0.9.1"
32+
source = "registry+https://github.com/rust-lang/crates.io-index"
33+
checksum = "c3b9d411ecbaf79885c6df4d75fff75858d5995ff25385657a28af47e82f9c36"
34+
dependencies = [
35+
"unicode-width",
36+
"yansi-term",
37+
]
38+
39+
[[package]]
40+
name = "ansi_term"
41+
version = "0.12.1"
42+
source = "registry+https://github.com/rust-lang/crates.io-index"
43+
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
44+
dependencies = [
45+
"winapi",
46+
]
47+
2948
[[package]]
3049
name = "anyhow"
3150
version = "1.0.71"
@@ -159,6 +178,25 @@ dependencies = [
159178
"windows-sys 0.48.0",
160179
]
161180

181+
[[package]]
182+
name = "comma"
183+
version = "1.0.0"
184+
source = "registry+https://github.com/rust-lang/crates.io-index"
185+
checksum = "55b672471b4e9f9e95499ea597ff64941a309b2cdbffcc46f2cc5e2d971fd335"
186+
187+
[[package]]
188+
name = "console"
189+
version = "0.15.7"
190+
source = "registry+https://github.com/rust-lang/crates.io-index"
191+
checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8"
192+
dependencies = [
193+
"encode_unicode",
194+
"lazy_static",
195+
"libc",
196+
"unicode-width",
197+
"windows-sys 0.45.0",
198+
]
199+
162200
[[package]]
163201
name = "crossbeam-channel"
164202
version = "0.5.8"
@@ -189,10 +227,10 @@ dependencies = [
189227
]
190228

191229
[[package]]
192-
name = "diff"
193-
version = "0.1.13"
230+
name = "encode_unicode"
231+
version = "0.3.6"
194232
source = "registry+https://github.com/rust-lang/crates.io-index"
195-
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
233+
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
196234

197235
[[package]]
198236
name = "env_logger"
@@ -282,6 +320,19 @@ version = "0.3.3"
282320
source = "registry+https://github.com/rust-lang/crates.io-index"
283321
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
284322

323+
[[package]]
324+
name = "indicatif"
325+
version = "0.17.7"
326+
source = "registry+https://github.com/rust-lang/crates.io-index"
327+
checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25"
328+
dependencies = [
329+
"console",
330+
"instant",
331+
"number_prefix",
332+
"portable-atomic",
333+
"unicode-width",
334+
]
335+
285336
[[package]]
286337
name = "instant"
287338
version = "0.1.12"
@@ -325,6 +376,12 @@ version = "1.4.0"
325376
source = "registry+https://github.com/rust-lang/crates.io-index"
326377
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
327378

379+
[[package]]
380+
name = "levenshtein"
381+
version = "1.0.5"
382+
source = "registry+https://github.com/rust-lang/crates.io-index"
383+
checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760"
384+
328385
[[package]]
329386
name = "libc"
330387
version = "0.2.148"
@@ -463,6 +520,12 @@ dependencies = [
463520
"static_assertions",
464521
]
465522

523+
[[package]]
524+
name = "number_prefix"
525+
version = "0.4.0"
526+
source = "registry+https://github.com/rust-lang/crates.io-index"
527+
checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
528+
466529
[[package]]
467530
name = "object"
468531
version = "0.30.3"
@@ -484,6 +547,15 @@ version = "3.5.0"
484547
source = "registry+https://github.com/rust-lang/crates.io-index"
485548
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
486549

550+
[[package]]
551+
name = "pad"
552+
version = "0.1.6"
553+
source = "registry+https://github.com/rust-lang/crates.io-index"
554+
checksum = "d2ad9b889f1b12e0b9ee24db044b5129150d5eada288edc800f789928dc8c0e3"
555+
dependencies = [
556+
"unicode-width",
557+
]
558+
487559
[[package]]
488560
name = "parking_lot"
489561
version = "0.11.2"
@@ -524,12 +596,28 @@ version = "0.2.9"
524596
source = "registry+https://github.com/rust-lang/crates.io-index"
525597
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
526598

599+
[[package]]
600+
name = "portable-atomic"
601+
version = "1.4.3"
602+
source = "registry+https://github.com/rust-lang/crates.io-index"
603+
checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b"
604+
527605
[[package]]
528606
name = "ppv-lite86"
529607
version = "0.2.17"
530608
source = "registry+https://github.com/rust-lang/crates.io-index"
531609
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
532610

611+
[[package]]
612+
name = "prettydiff"
613+
version = "0.6.4"
614+
source = "registry+https://github.com/rust-lang/crates.io-index"
615+
checksum = "8ff1fec61082821f8236cf6c0c14e8172b62ce8a72a0eedc30d3b247bb68dc11"
616+
dependencies = [
617+
"ansi_term",
618+
"pad",
619+
]
620+
533621
[[package]]
534622
name = "proc-macro2"
535623
version = "1.0.66"
@@ -859,18 +947,23 @@ dependencies = [
859947

860948
[[package]]
861949
name = "ui_test"
862-
version = "0.11.7"
950+
version = "0.21.1"
863951
source = "registry+https://github.com/rust-lang/crates.io-index"
864-
checksum = "c21899b59f53717dfad29e4f46e5b21a200a1b6888ab86532a07cfc8b48dd78c"
952+
checksum = "accffe020b57a6dd50014d457b5842c5a2ca73cd84f07d86d0a19c460a6509ae"
865953
dependencies = [
954+
"annotate-snippets",
955+
"anyhow",
866956
"bstr",
867957
"cargo-platform",
868958
"cargo_metadata",
869959
"color-eyre",
870960
"colored",
961+
"comma",
871962
"crossbeam-channel",
872-
"diff",
963+
"indicatif",
873964
"lazy_static",
965+
"levenshtein",
966+
"prettydiff",
874967
"regex",
875968
"rustc_version",
876969
"rustfix",
@@ -885,6 +978,12 @@ version = "1.0.8"
885978
source = "registry+https://github.com/rust-lang/crates.io-index"
886979
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
887980

981+
[[package]]
982+
name = "unicode-width"
983+
version = "0.1.11"
984+
source = "registry+https://github.com/rust-lang/crates.io-index"
985+
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
986+
888987
[[package]]
889988
name = "valuable"
890989
version = "0.1.0"
@@ -1059,3 +1158,12 @@ name = "windows_x86_64_msvc"
10591158
version = "0.48.0"
10601159
source = "registry+https://github.com/rust-lang/crates.io-index"
10611160
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
1161+
1162+
[[package]]
1163+
name = "yansi-term"
1164+
version = "0.1.2"
1165+
source = "registry+https://github.com/rust-lang/crates.io-index"
1166+
checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1"
1167+
dependencies = [
1168+
"winapi",
1169+
]

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.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"] }

src/tools/miri/README.md

Lines changed: 2 additions & 0 deletions

src/tools/miri/tests/compiletest.rs

Lines changed: 46 additions & 55 deletions
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

Lines changed: 1 addition & 1 deletion
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)