Skip to content

Make output more like libtest #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub type Filter = Vec<(Match, &'static [u8])>;
pub fn run_tests(config: Config) -> Result<()> {
let args = Args::test();
if !args.quiet {
eprintln!(" Compiler: {}", config.program.display());
eprintln!("Compiler: {}", config.program.display());
}

let name = config.root_dir.display().to_string();
Expand Down
56 changes: 33 additions & 23 deletions src/status_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use bstr::ByteSlice;
use colored::Colorize;
use crossbeam_channel::{Sender, TryRecvError};
use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget};
use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle};

use crate::{
github_actions, parser::Pattern, rustc_stderr::Message, Error, Errored, Errors, TestOk,
Expand Down Expand Up @@ -108,14 +108,15 @@ impl Text {
}
}
Msg::Status(msg, status) => {
threads
.get_mut(&msg)
.unwrap()
.set_message(format!("{msg} {status}"));
threads.get_mut(&msg).unwrap().set_message(status);
}
Msg::Push(msg) => {
let spinner =
bars.add(ProgressBar::new_spinner().with_message(msg.clone()));
bars.add(ProgressBar::new_spinner().with_prefix(msg.clone()));
spinner.set_style(
ProgressStyle::with_template("{prefix} {spinner}{msg}")
.unwrap(),
);
threads.insert(msg, spinner);
}
Msg::IncLength => {
Expand Down Expand Up @@ -194,9 +195,9 @@ impl TestStatus for TextTest {
Ok(TestOk::Filtered) => return,
};
let old_msg = self.msg();
let msg = format!("{old_msg} ... {result}");
let msg = format!("... {result}");
if ProgressDrawTarget::stderr().is_hidden() {
eprintln!("{msg}");
eprintln!("{old_msg} {msg}");
std::io::stderr().flush().unwrap();
} else {
self.text.sender.send(Msg::Pop(old_msg, Some(msg))).unwrap();
Expand Down Expand Up @@ -288,13 +289,17 @@ impl StatusEmitter for Text {
// Print all errors in a single thread to show reliable output
if failures == 0 {
eprintln!();
eprintln!(
"test result: {}. {} tests passed, {} ignored, {} filtered out",
"ok".green(),
succeeded.to_string().green(),
ignored.to_string().yellow(),
filtered.to_string().yellow(),
);
eprint!("test result: {}.", "ok".green());
if succeeded > 0 {
eprint!(" {} passed;", succeeded.to_string().green());
}
if ignored > 0 {
eprint!(" {} ignored;", ignored.to_string().yellow());
}
if filtered > 0 {
eprint!(" {} filtered out;", filtered.to_string().yellow());
}
eprintln!();
eprintln!();
Box::new(())
} else {
Expand Down Expand Up @@ -330,14 +335,19 @@ impl StatusEmitter for Text {
eprintln!("{line}");
}
eprintln!();
eprintln!(
"test result: {}. {} tests failed, {} tests passed, {} ignored, {} filtered out",
"FAIL".red(),
self.failures.len().to_string().red().bold(),
self.succeeded.to_string().green(),
self.ignored.to_string().yellow(),
self.filtered.to_string().yellow(),
);
eprint!("test result: {}.", "FAIL".red());
eprint!(" {} failed;", self.failures.len().to_string().green());
if self.succeeded > 0 {
eprint!(" {} passed;", self.succeeded.to_string().green());
}
if self.ignored > 0 {
eprint!(" {} ignored;", self.ignored.to_string().yellow());
}
if self.filtered > 0 {
eprint!(" {} filtered out;", self.filtered.to_string().yellow());
}
eprintln!();
eprintln!();
}
}
Box::new(Summarizer {
Expand Down
3 changes: 0 additions & 3 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ fn run(name: &str, mode: Mode) -> Result<()> {
config.stderr_filter("(src/.*?\\.rs):[0-9]+:[0-9]+", "$1:LL:CC");
config.stderr_filter("program not found", "No such file or directory");
config.stderr_filter(" \\(os error [0-9]+\\)", "");
// We emit this message on a thread, so it can sometimes happen that it
// appears earlier or later than the regular test messages.
config.stderr_filter(" Building test dependencies...\n", "");

let text = if args.quiet {
ui_test::status_emitter::Text::quiet()
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/basic-bin/Cargo.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Building dependencies ... ok
tests/actual_tests/foomp.rs ... ok

test result: ok. 1 tests passed, 0 ignored, 0 filtered out
test result: ok. 1 passed;

2 changes: 1 addition & 1 deletion tests/integrations/basic-fail-mode/Cargo.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Building dependencies ... ok
tests/actual_tests/foomp.rs ... ok

test result: ok. 1 tests passed, 0 ignored, 0 filtered out
test result: ok. 1 passed;

12 changes: 8 additions & 4 deletions tests/integrations/basic-fail/Cargo.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ FAILURES:
tests/actual_tests/foomp2.rs
tests/actual_tests/pattern_too_many_arrow.rs

test result: FAIL. 8 tests failed, 0 tests passed, 0 ignored, 0 filtered out
test result: FAIL. 8 failed;

Error: tests failed

Location:
Expand Down Expand Up @@ -557,7 +558,8 @@ FAILURES:
tests/actual_tests_bless/unknown_revision.rs
tests/actual_tests_bless/unknown_revision2.rs

test result: FAIL. 18 tests failed, 14 tests passed, 3 ignored, 0 filtered out
test result: FAIL. 18 failed; 14 passed; 3 ignored;

Building dependencies ... ok
tests/actual_tests_bless_yolo/revisions_bad.rs (foo) ... ok
tests/actual_tests_bless_yolo/revisions_bad.rs (bar) ... FAILED
Expand All @@ -584,7 +586,8 @@ For more information about this error, try `rustc --explain E0601`.
FAILURES:
tests/actual_tests_bless_yolo/revisions_bad.rs (revision bar)

test result: FAIL. 1 tests failed, 2 tests passed, 0 ignored, 0 filtered out
test result: FAIL. 1 failed; 2 passed;

thread 'main' panicked at 'invalid mode/result combo: yolo: Err(tests failed

Location:
Expand Down Expand Up @@ -703,7 +706,8 @@ FAILURES:
tests/actual_tests/foomp2.rs
tests/actual_tests/pattern_too_many_arrow.rs

test result: FAIL. 8 tests failed, 0 tests passed, 0 ignored, 0 filtered out
test result: FAIL. 8 failed;

Error: tests failed

Location:
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/basic/Cargo.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ tests/actual_tests/unicode.rs ... ok
tests/actual_tests/windows_paths.rs ... ok
tests/actual_tests/subdir/aux_proc_macro.rs ... ok

test result: ok. 9 tests passed, 0 ignored, 0 filtered out
test result: ok. 9 passed;