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

Commit 68041b4

Browse files
committed
Print one character per test instead of one line
1 parent 30931ee commit 68041b4

File tree

3 files changed

+48
-14
lines changed

3 files changed

+48
-14
lines changed

tests/compiletest.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,17 @@ fn run_tests(mode: Mode, path: &str, target: Option<String>) -> Result<()> {
4848
(true, true) => panic!("cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time"),
4949
};
5050

51-
// Pass on all arguments as filters.
52-
let path_filter = std::env::args().skip(1);
51+
// Pass on all unknown arguments as filters.
52+
let mut quiet = false;
53+
let path_filter = std::env::args().skip(1).filter(|arg| {
54+
match &**arg {
55+
"--quiet" => {
56+
quiet = true;
57+
false
58+
}
59+
_ => true,
60+
}
61+
});
5362

5463
let use_std = env::var_os("MIRI_NO_STD").is_none();
5564

@@ -76,6 +85,7 @@ fn run_tests(mode: Mode, path: &str, target: Option<String>) -> Result<()> {
7685
],
7786
envs: vec![],
7887
}),
88+
quiet,
7989
};
8090
ui_test::run_tests(config)
8191
}

ui_test/src/lib.rs

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ pub struct Config {
4646
/// Can be used to override what command to run instead of `cargo` to build the
4747
/// dependencies in `manifest_path`
4848
pub dependency_builder: Option<DependencyBuilder>,
49+
/// Print one character per test instead of one line
50+
pub quiet: bool,
4951
}
5052

5153
#[derive(Debug)]
@@ -125,10 +127,38 @@ pub fn run_tests(mut config: Config) -> Result<()> {
125127

126128
// A channel for the messages emitted by the individual test threads.
127129
let (finish_file, finished_files) = crossbeam::channel::unbounded();
130+
enum TestResult {
131+
Ok,
132+
Failed,
133+
Ignored,
134+
}
128135

129136
s.spawn(|_| {
130-
for msg in finished_files {
131-
eprintln!("{msg}");
137+
if config.quiet {
138+
for (i, (_, result)) in finished_files.into_iter().enumerate() {
139+
// Humans start counting at 1
140+
let i = i + 1;
141+
match result {
142+
TestResult::Ok => eprint!("{}", ".".green()),
143+
TestResult::Failed => eprint!("{}", "F".red().bold()),
144+
TestResult::Ignored => eprint!("{}", "i".yellow()),
145+
}
146+
if i % 100 == 0 {
147+
eprintln!(" {i}");
148+
}
149+
}
150+
} else {
151+
for (msg, result) in finished_files {
152+
eprint!("{msg} ... ");
153+
eprintln!(
154+
"{}",
155+
match result {
156+
TestResult::Ok => "ok".green(),
157+
TestResult::Failed => "FAILED".red().bold(),
158+
TestResult::Ignored => "ignored (in-test comment)".yellow(),
159+
}
160+
);
161+
}
132162
}
133163
});
134164

@@ -151,12 +181,7 @@ pub fn run_tests(mut config: Config) -> Result<()> {
151181
// Ignore file if only/ignore rules do (not) apply
152182
if !test_file_conditions(&comments, &target, &config) {
153183
ignored.fetch_add(1, Ordering::Relaxed);
154-
let msg = format!(
155-
"{} ... {}",
156-
path.display(),
157-
"ignored (in-test comment)".yellow()
158-
);
159-
finish_file.send(msg)?;
184+
finish_file.send((path.display().to_string(), TestResult::Ignored))?;
160185
continue;
161186
}
162187
// Run the test for all revisions
@@ -171,12 +196,11 @@ pub fn run_tests(mut config: Config) -> Result<()> {
171196
if !revision.is_empty() {
172197
write!(msg, "(revision `{revision}`) ").unwrap();
173198
}
174-
write!(msg, "... ").unwrap();
175199
if errors.is_empty() {
176-
write!(msg, "{}", "ok".green()).unwrap();
200+
finish_file.send((msg, TestResult::Ok))?;
177201
succeeded.fetch_add(1, Ordering::Relaxed);
178202
} else {
179-
write!(msg, "{}", "FAILED".red().bold()).unwrap();
203+
finish_file.send((msg, TestResult::Failed))?;
180204
failures.lock().unwrap().push((
181205
path.clone(),
182206
m,
@@ -185,7 +209,6 @@ pub fn run_tests(mut config: Config) -> Result<()> {
185209
stderr,
186210
));
187211
}
188-
finish_file.send(msg)?;
189212
}
190213
}
191214
Ok(())

ui_test/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fn config() -> Config {
1818
output_conflict_handling: OutputConflictHandling::Error,
1919
dependencies_crate_manifest_path: None,
2020
dependency_builder: None,
21+
quiet: false,
2122
}
2223
}
2324

0 commit comments

Comments
 (0)