From 8d671a71a72aa0f94eb003cbe2010647dfa9a081 Mon Sep 17 00:00:00 2001 From: can1357 Date: Fri, 19 Jun 2026 03:35:53 +0200 Subject: [PATCH] refactor(pi-shell): improved test readability and formatting - Updated line wrapping in module documentation and test blocks for consistent style. - Adjusted variable assignment formatting in the segmented chain test to improve readability. --- crates/pi-shell/src/minimizer/plan.rs | 10 ++++++++-- crates/pi-shell/src/shell.rs | 15 +++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/crates/pi-shell/src/minimizer/plan.rs b/crates/pi-shell/src/minimizer/plan.rs index a21ac2c79..1cab90049 100644 --- a/crates/pi-shell/src/minimizer/plan.rs +++ b/crates/pi-shell/src/minimizer/plan.rs @@ -226,12 +226,18 @@ fn io_redirect_is_safe(io: &IoRedirect) -> bool { /// [`reconstruction_reparses_to_same_shape`] before any segment is executed. fn simple_command_is_safe(simple: &SimpleCommand) -> bool { if let Some(prefix) = simple.prefix.as_ref() - && prefix.0.iter().any(|item| !command_prefix_or_suffix_item_is_safe(item)) + && prefix + .0 + .iter() + .any(|item| !command_prefix_or_suffix_item_is_safe(item)) { return false; } if let Some(suffix) = simple.suffix.as_ref() - && suffix.0.iter().any(|item| !command_prefix_or_suffix_item_is_safe(item)) + && suffix + .0 + .iter() + .any(|item| !command_prefix_or_suffix_item_is_safe(item)) { return false; } diff --git a/crates/pi-shell/src/shell.rs b/crates/pi-shell/src/shell.rs index 42a28b3ed..9ac8a7ff8 100644 --- a/crates/pi-shell/src/shell.rs +++ b/crates/pi-shell/src/shell.rs @@ -2266,11 +2266,12 @@ replace = [{ pattern = "^.+$", replacement = "PWD" }] /// A segment that carries a file redirect is still segmented, and the brush /// `Display` reconstruction the runner executes must round-trip through - /// brush's own parser **without losing the redirect**. `echo hidden >/dev/null` - /// suppresses its own stdout: if the reconstruction dropped the redirect, - /// `hidden` would leak into the captured output. Proves the reconstruction - /// path is semantically sound for the redirect-bearing shapes the per-stage - /// whitelist accepts (not just syntactically parseable). + /// brush's own parser **without losing the redirect**. `echo hidden + /// >/dev/null` suppresses its own stdout: if the reconstruction dropped the + /// redirect, `hidden` would leak into the captured output. Proves the + /// reconstruction path is semantically sound for the redirect-bearing + /// shapes the per-stage whitelist accepts (not just syntactically + /// parseable). #[cfg(unix)] #[tokio::test(flavor = "multi_thread")] async fn segmented_chain_with_redirect_executes_correctly() { @@ -2289,7 +2290,9 @@ replace = [{ pattern = "^.+$", replacement = "PWD" }] // /dev/null, so only segment 2's output is captured. assert!(!output.contains("hidden"), "redirect must suppress segment-1 stdout"); assert_eq!(output, "hello\n"); - let minimized = result.minimized.expect("redirect chain should be minimized"); + let minimized = result + .minimized + .expect("redirect chain should be minimized"); assert_eq!(minimized.original_text, "hello\n"); assert_eq!(minimized.text, "HI\n"); assert!(!output.contains("syntax error"));