test: tolerate closed stdin in chunk-size failure
The chunk-size-zero regression test spawned fcry with stdin piped and unconditionally unwrapped the write into that pipe. That made the test depend on scheduler timing: the child may validate --chunk-size 0, report the error, and exit before it has drained stdin. Treat BrokenPipe as the expected early-exit shape for this failing command, while still failing on any other write error and still asserting that the process exits unsuccessfully. The valid empty-stdin chunk-size case remains unchanged. Test Plan: - cargo fmt --check - cargo test - cargo clippy --all-targets -- -D warnings - git diff --check Refs: none
This commit is contained in:
+9
-2
@@ -7,7 +7,7 @@
|
||||
// wrong key, truncation, bad magic).
|
||||
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::io::{ErrorKind, Write};
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
use assert_cmd::cargo::CommandCargoExt;
|
||||
@@ -915,7 +915,14 @@ fn stdin_chunk_size_zero_fails_but_empty_valid_chunk_succeeds() {
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.unwrap();
|
||||
bad.stdin.as_mut().unwrap().write_all(b"x").unwrap();
|
||||
// Invalid options can make the child exit before it drains stdin.
|
||||
if let Err(err) = bad.stdin.as_mut().unwrap().write_all(b"x") {
|
||||
assert_eq!(
|
||||
err.kind(),
|
||||
ErrorKind::BrokenPipe,
|
||||
"unexpected stdin write error for failing chunk-size 0 process: {err}"
|
||||
);
|
||||
}
|
||||
let bad_out = bad.wait_with_output().unwrap();
|
||||
assert!(!bad_out.status.success(), "chunk-size 0 should fail");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user