merge PR #5671 via eval/pr-5671: fix(bash): drained piped output before timeout return

This commit is contained in:
can1357
2026-07-17 04:37:11 +02:00
6 changed files with 85 additions and 5 deletions
+27
View File
@@ -558,4 +558,31 @@ mod tests {
.expect("shell run should return");
assert!(result.cancelled);
}
#[tokio::test(flavor = "multi_thread")]
async fn timeout_drains_pipeline_output_before_stopping_reader() {
let shell = CoreShell::new(None);
let (tx, rx) = flume::unbounded::<String>();
let result = shell
.run(
CoreShellRunOptions {
command: "yes x | tail -5".to_string(),
cwd: None,
env: None,
timeout_ms: Some(50),
},
Some(tx),
CancelToken::new(Some(50)),
)
.await
.expect("shell run");
let mut output = String::new();
while let Ok(chunk) = rx.recv_async().await {
output.push_str(&chunk);
}
assert!(result.timed_out);
assert_eq!(output.lines().filter(|line| *line == "x").count(), 5);
}
}