Skip to content

compiletest: change a eprintln back to println #134206

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

Closed
wants to merge 2 commits into from
Closed
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
47 changes: 24 additions & 23 deletions src/bootstrap/src/utils/render_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ pub(crate) fn try_run_tests(
}
}

// NOTE: note that here, we consistently output all messages to stdout, because that's where
// compiletest + libtest output is going to be forwarded to. If we interleave stderr/stdout output,
// they will be combined in terminals then produce garbled interleavings.
fn run_tests(builder: &Builder<'_>, cmd: &mut BootstrapCommand, stream: bool) -> bool {
let cmd = cmd.as_command_mut();
cmd.stdout(Stdio::piped());

builder.verbose(|| eprintln!("running: {cmd:?}"));
builder.verbose(|| println!("running: {cmd:?}"));

let mut process = cmd.spawn().unwrap();

Expand All @@ -71,7 +74,7 @@ fn run_tests(builder: &Builder<'_>, cmd: &mut BootstrapCommand, stream: bool) ->

let result = process.wait_with_output().unwrap();
if !result.status.success() && builder.is_verbose() {
eprintln!(
println!(
"\n\ncommand did not execute successfully: {cmd:?}\n\
expected success, got: {}",
result.status
Expand Down Expand Up @@ -135,9 +138,7 @@ impl<'a> Renderer<'a> {
if self.up_to_date_tests > 0 {
let n = self.up_to_date_tests;
let s = if n > 1 { "s" } else { "" };
eprintln!(
"help: ignored {n} up-to-date test{s}; use `--force-rerun` to prevent this\n"
);
println!("help: ignored {n} up-to-date test{s}; use `--force-rerun` to prevent this\n");
}
}

Expand Down Expand Up @@ -187,22 +188,22 @@ impl<'a> Renderer<'a> {
}

fn render_test_outcome_verbose(&self, outcome: Outcome<'_>, test: &TestOutcome) {
eprint!("test {} ... ", test.name);
print!("test {} ... ", test.name);
self.builder.colored_stderr(|stdout| outcome.write_long(stdout)).unwrap();
if let Some(exec_time) = test.exec_time {
eprint!(" ({exec_time:.2?})");
print!(" ({exec_time:.2?})");
}
eprintln!();
println!();
}

fn render_test_outcome_terse(&mut self, outcome: Outcome<'_>, test: &TestOutcome) {
if self.terse_tests_in_line != 0 && self.terse_tests_in_line % TERSE_TESTS_PER_LINE == 0 {
if let Some(total) = self.tests_count {
let total = total.to_string();
let executed = format!("{:>width$}", self.executed_tests - 1, width = total.len());
eprint!(" {executed}/{total}");
print!(" {executed}/{total}");
}
eprintln!();
println!();
self.terse_tests_in_line = 0;
}

Expand All @@ -214,31 +215,31 @@ impl<'a> Renderer<'a> {
fn render_suite_outcome(&self, outcome: Outcome<'_>, suite: &SuiteOutcome) {
// The terse output doesn't end with a newline, so we need to add it ourselves.
if !self.builder.config.verbose_tests {
eprintln!();
println!();
}

if !self.failures.is_empty() {
eprintln!("\nfailures:\n");
println!("\nfailures:\n");
for failure in &self.failures {
if failure.stdout.is_some() || failure.message.is_some() {
eprintln!("---- {} stdout ----", failure.name);
println!("---- {} stdout ----", failure.name);
if let Some(stdout) = &failure.stdout {
eprintln!("{stdout}");
println!("{stdout}");
}
if let Some(message) = &failure.message {
eprintln!("NOTE: {message}");
println!("NOTE: {message}");
}
}
}

eprintln!("\nfailures:");
println!("\nfailures:");
for failure in &self.failures {
eprintln!(" {}", failure.name);
println!(" {}", failure.name);
}
}

if !self.benches.is_empty() {
eprintln!("\nbenchmarks:");
println!("\nbenchmarks:");

let mut rows = Vec::new();
for bench in &self.benches {
Expand All @@ -253,13 +254,13 @@ impl<'a> Renderer<'a> {
let max_1 = rows.iter().map(|r| r.1.len()).max().unwrap_or(0);
let max_2 = rows.iter().map(|r| r.2.len()).max().unwrap_or(0);
for row in &rows {
eprintln!(" {:<max_0$} {:>max_1$} {:>max_2$}", row.0, row.1, row.2);
println!(" {:<max_0$} {:>max_1$} {:>max_2$}", row.0, row.1, row.2);
}
}

eprint!("\ntest result: ");
print!("\ntest result: ");
self.builder.colored_stderr(|stdout| outcome.write_long(stdout)).unwrap();
eprintln!(
println!(
". {} passed; {} failed; {} ignored; {} measured; {} filtered out{time}\n",
suite.passed,
suite.failed,
Expand All @@ -276,7 +277,7 @@ impl<'a> Renderer<'a> {
fn render_message(&mut self, message: Message) {
match message {
Message::Suite(SuiteMessage::Started { test_count }) => {
eprintln!("\nrunning {test_count} tests");
println!("\nrunning {test_count} tests");
self.executed_tests = 0;
self.terse_tests_in_line = 0;
self.tests_count = Some(test_count);
Expand Down Expand Up @@ -316,7 +317,7 @@ impl<'a> Renderer<'a> {
self.failures.push(outcome);
}
Message::Test(TestMessage::Timeout { name }) => {
eprintln!("test {name} has been running for a long time");
println!("test {name} has been running for a long time");
}
Message::Test(TestMessage::Started) => {} // Not useful
}
Expand Down
4 changes: 3 additions & 1 deletion src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ pub fn run_tests(config: Arc<Config>) {
// easy to miss which tests failed, and as such fail to reproduce
// the failure locally.

eprintln!(
// Note: this needs to output to stderr because that's where libtest
// also outputs the dots to.
println!(
"Some tests failed in compiletest suite={}{} mode={} host={} target={}",
config.suite,
config
Expand Down
5 changes: 5 additions & 0 deletions tests/run-make/selftest/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
println!("hewwo");
eprintln!("owo");
panic!("get rotated idiot");
}
Loading