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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user