Skip to content

Commit b9b06f1

Browse files
committed
Print one character per test instead of one line
1 parent a4a96b9 commit b9b06f1

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 config = Config {
5564
args: flags,
@@ -61,6 +70,7 @@ fn run_tests(mode: Mode, path: &str, target: Option<String>) -> Result<()> {
6170
path_filter: path_filter.collect(),
6271
program: miri_path(),
6372
output_conflict_handling,
73+
quiet,
6474
};
6575
ui_test::run_tests(config)
6676
}

ui_test/src/lib.rs

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ pub struct Config {
3838
pub output_conflict_handling: OutputConflictHandling,
3939
/// Only run tests with one of these strings in their path/name
4040
pub path_filter: Vec<String>,
41+
/// Print one character per test instead of one line
42+
pub quiet: bool,
4143
}
4244

4345
#[derive(Debug)]
@@ -96,10 +98,38 @@ pub fn run_tests(config: Config) -> Result<()> {
9698

9799
// A channel for the messages emitted by the individual test threads.
98100
let (finish_file, finished_files) = crossbeam::channel::unbounded();
101+
enum TestResult {
102+
Ok,
103+
Failed,
104+
Ignored,
105+
}
99106

100107
s.spawn(|_| {
101-
for msg in finished_files {
102-
eprintln!("{msg}");
108+
if config.quiet {
109+
for (i, (_, result)) in finished_files.into_iter().enumerate() {
110+
// Humans start counting at 1
111+
let i = i + 1;
112+
match result {
113+
TestResult::Ok => eprint!("{}", ".".green()),
114+
TestResult::Failed => eprint!("{}", "F".red().bold()),
115+
TestResult::Ignored => eprint!("{}", "i".yellow()),
116+
}
117+
if i % 100 == 0 {
118+
eprintln!(" {i}");
119+
}
120+
}
121+
} else {
122+
for (msg, result) in finished_files {
123+
eprint!("{msg} ... ");
124+
eprintln!(
125+
"{}",
126+
match result {
127+
TestResult::Ok => "ok".green(),
128+
TestResult::Failed => "FAILED".red().bold(),
129+
TestResult::Ignored => "ignored (in-test comment)".yellow(),
130+
}
131+
);
132+
}
103133
}
104134
});
105135

@@ -122,12 +152,7 @@ pub fn run_tests(config: Config) -> Result<()> {
122152
// Ignore file if only/ignore rules do (not) apply
123153
if !test_file_conditions(&comments, &target, &config) {
124154
ignored.fetch_add(1, Ordering::Relaxed);
125-
let msg = format!(
126-
"{} ... {}",
127-
path.display(),
128-
"ignored (in-test comment)".yellow()
129-
);
130-
finish_file.send(msg)?;
155+
finish_file.send((path.display().to_string(), TestResult::Ignored))?;
131156
continue;
132157
}
133158
// Run the test for all revisions
@@ -142,12 +167,11 @@ pub fn run_tests(config: Config) -> Result<()> {
142167
if !revision.is_empty() {
143168
write!(msg, "(revision `{revision}`) ").unwrap();
144169
}
145-
write!(msg, "... ").unwrap();
146170
if errors.is_empty() {
147-
write!(msg, "{}", "ok".green()).unwrap();
171+
finish_file.send((msg, TestResult::Ok))?;
148172
succeeded.fetch_add(1, Ordering::Relaxed);
149173
} else {
150-
write!(msg, "{}", "FAILED".red().bold()).unwrap();
174+
finish_file.send((msg, TestResult::Failed))?;
151175
failures.lock().unwrap().push((
152176
path.clone(),
153177
m,
@@ -156,7 +180,6 @@ pub fn run_tests(config: Config) -> Result<()> {
156180
stderr,
157181
));
158182
}
159-
finish_file.send(msg)?;
160183
}
161184
}
162185
Ok(())

ui_test/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fn config() -> Config {
1616
path_filter: vec![],
1717
program: PathBuf::from("cake"),
1818
output_conflict_handling: OutputConflictHandling::Error,
19+
quiet: false,
1920
}
2021
}
2122

0 commit comments

Comments
 (0)