Skip to content
Open
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
17 changes: 15 additions & 2 deletions src/cmds/go/golangci_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use crate::core::config;
use crate::core::runner;
use crate::core::stream::exec_capture;
use crate::core::truncate::CAP_WARNINGS;
use crate::core::utils::{resolved_command, truncate};
use crate::core::utils::resolved_command;
use crate::parser::truncate_output;
use anyhow::Result;
use serde::Deserialize;
use std::collections::HashMap;
Expand Down Expand Up @@ -271,7 +272,7 @@ pub(crate) fn filter_golangci_json(output: &str, version: u32) -> String {
return format!(
"golangci-lint (JSON parse failed: {})\n{}",
e,
truncate(output, config::limits().passthrough_max_chars)
truncate_output(output, config::limits().passthrough_max_chars)
);
}
};
Expand Down Expand Up @@ -431,6 +432,18 @@ mod tests {
assert!(result.contains("utils.go"));
}

#[test]
fn test_filter_golangci_parse_failure_marks_truncated_passthrough() {
let long_invalid_json = "{".repeat(crate::core::config::limits().passthrough_max_chars + 20);
let result = filter_golangci_json(&long_invalid_json, 2);

assert!(result.contains("golangci-lint (JSON parse failed:"));
assert!(
result.contains("[RTK:PASSTHROUGH] Output truncated"),
"parse fallback should make truncation visible, got:\n{result}"
);
}

#[test]
fn test_compact_path() {
assert_eq!(
Expand Down
15 changes: 14 additions & 1 deletion src/cmds/python/ruff_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::core::config;
use crate::core::runner;
use crate::core::truncate::CAP_WARNINGS;
use crate::core::utils::{resolved_command, truncate};
use crate::parser::truncate_output;
use anyhow::Result;
use serde::Deserialize;
use std::collections::HashMap;
Expand Down Expand Up @@ -101,7 +102,7 @@ pub fn filter_ruff_check_json(output: &str) -> String {
return format!(
"Ruff check (JSON parse failed: {})\n{}",
e,
truncate(output, config::limits().passthrough_max_chars)
truncate_output(output, config::limits().passthrough_max_chars)
);
}
};
Expand Down Expand Up @@ -387,6 +388,18 @@ mod tests {
assert!(result.contains("1:8"), "line:col location missing");
}

#[test]
fn test_filter_ruff_check_parse_failure_marks_truncated_passthrough() {
let long_invalid_json = "{".repeat(crate::core::config::limits().passthrough_max_chars + 20);
let result = filter_ruff_check_json(&long_invalid_json);

assert!(result.contains("Ruff check (JSON parse failed:"));
assert!(
result.contains("[RTK:PASSTHROUGH] Output truncated"),
"parse fallback should make truncation visible, got:\n{result}"
);
}

#[test]
fn test_filter_ruff_format_all_formatted() {
let output = "5 files left unchanged";
Expand Down