Skip to content
Open
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
22 changes: 21 additions & 1 deletion src/cmds/rust/cargo_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ impl BlockHandler for CargoBuildHandler {
!(line.trim().is_empty() && block.len() > 3)
}

fn format_summary(&self, _exit_code: i32, _raw: &str) -> Option<String> {
fn format_summary(&self, _exit_code: i32, raw: &str) -> Option<String> {
if raw.trim().is_empty() {
return None;
}

if self.error_count == 0 && self.warnings == 0 {
let mut s = format!("cargo build ({} crates compiled)", self.compiled);
if let Some(ref finished) = self.finished_line {
Expand Down Expand Up @@ -758,6 +762,10 @@ fn filter_cargo_nextest(output: &str) -> String {
}

fn filter_cargo_build(output: &str) -> String {
if output.trim().is_empty() {
return String::new();
}

let mut handler = CargoBuildHandler::new();
let mut blocks: Vec<Vec<String>> = Vec::new();
let mut current_block: Vec<String> = Vec::new();
Expand Down Expand Up @@ -1353,6 +1361,11 @@ mod tests {
assert!(result.contains("3 crates compiled"));
}

#[test]
fn test_filter_cargo_build_quiet_success_preserves_empty_output() {
assert_eq!(filter_cargo_build(""), "");
}

#[test]
fn test_filter_cargo_build_errors() {
let output = r#" Compiling rtk v0.5.0
Expand Down Expand Up @@ -2110,6 +2123,13 @@ error: test run failed
assert!(!result.contains("Compiling"), "got: {}", result);
}

#[test]
fn test_cargo_build_stream_quiet_success_preserves_empty_output() {
let mut f = BlockStreamFilter::new(CargoBuildHandler::new());
let result = run_block_filter(&mut f, "", 0);
assert_eq!(result, "");
}

#[test]
fn test_cargo_build_stream_errors() {
let input = r#" Compiling rtk v0.5.0
Expand Down
Loading