From d652ed8c00bb84503d3f4c75c4a30d6b9827e005 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 10 Aug 2026 18:37:36 +0800 Subject: fix(run): emit task failures to stdout on non-TTY Avoid ProgressBar swallowing error output in CI or piped contexts by printing directly to stdout when stdout is not a terminal. --- .run/src/lib.rs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.run/src/lib.rs b/.run/src/lib.rs index cff606a..05b8e12 100644 --- a/.run/src/lib.rs +++ b/.run/src/lib.rs @@ -3,6 +3,8 @@ pub mod verify; use colored::Colorize; +use std::io::IsTerminal as _; + #[macro_export] macro_rules! run_cmd { ($fmt:literal, $($arg:tt)*) => { @@ -275,15 +277,30 @@ pub fn run_parallel(phase: &str, tasks: Vec<(String, String, String)>) -> Result if first_exit_code == 0 { first_exit_code = code; } - pb.println(format!( + let msg = format!( "{}: {} failed (exit code {})", "error".bright_red().bold(), labels[i], code, - )); + ); + let mut lines = Vec::new(); if !output.is_empty() { - for line in output.lines() { - pb.println(format!(" {line}")); + lines.extend(output.lines().map(|l| format!(" {l}"))); + } + if std::io::stdout().is_terminal() { + // On a TTY, render errors through the progress bar so they + // appear above it. + pb.println(&msg); + for line in &lines { + pb.println(line); + } + } else { + // On a non-TTY (CI, piped output), `ProgressBar::println` can + // be swallowed, hiding the failure. Emit to plain stdout so the + // failure is always visible. + println!("{msg}"); + for line in &lines { + println!("{line}"); } } } -- cgit