cultcache-rs: pin that only a cultcache.store header claims a format
A file that opens like a store but carries some other string where the header goes is undecodable, not a store in a format this runtime does not read. cargo-mutants left the guard's `true` mutant alive without this case. The size-limited child's stdout and stderr now travel with the parent's failure message, so a child that fails for another reason says which. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
dc2a0a7eaa
commit
c0ab617e61
1 changed files with 18 additions and 4 deletions
|
|
@ -4800,7 +4800,14 @@ mod tests {
|
|||
let temp = tempfile::tempdir()?;
|
||||
let path = temp.path().join("store.cc");
|
||||
let store = SingleFileMessagePackBackingStore::new(&path);
|
||||
for bytes in [&b"not a store at all"[..], &[0x92, 0xa3, b'a', b'b'][..], &[0xc1][..]] {
|
||||
// The last opens like a store, with a string where the header goes, but only a
|
||||
// `cultcache.store.*` header claims a format this runtime might not read.
|
||||
for bytes in [
|
||||
&b"not a store at all"[..],
|
||||
&[0x92, 0xa3, b'a', b'b'][..],
|
||||
&[0xc1][..],
|
||||
&[0x92, 0xa2, b'a', b'b', 0x90][..],
|
||||
] {
|
||||
fs::write(&path, bytes)?;
|
||||
let error = store.pull_all().unwrap_err();
|
||||
assert_eq!(unreadable_kind(&error), Some(CultCacheStoreUnreadableKind::Undecodable), "{bytes:?}: {error:#}");
|
||||
|
|
@ -4875,13 +4882,20 @@ mod tests {
|
|||
let temp = tempfile::tempdir()?;
|
||||
let path = temp.path().join("store.cc");
|
||||
let (store, before) = written_store(&path)?;
|
||||
let status = std::process::Command::new("sh")
|
||||
let child = std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg("trap '' XFSZ; ulimit -f 64; exec \"$0\" --exact --test-threads=1 --quiet tests::a_write_that_fails_part_way_leaves_no_staging_file_and_keeps_the_store")
|
||||
.arg(std::env::current_exe()?)
|
||||
.env(CHILD_STORE, &path)
|
||||
.status()?;
|
||||
assert!(status.success(), "the size-limited child did not fail its write as expected: {status}");
|
||||
.output()?;
|
||||
assert!(
|
||||
child.status.success(),
|
||||
"the size-limited child did not fail its write as expected: {}
|
||||
{}{}",
|
||||
child.status,
|
||||
String::from_utf8_lossy(&child.stdout),
|
||||
String::from_utf8_lossy(&child.stderr)
|
||||
);
|
||||
|
||||
let staging: Vec<_> = fs::read_dir(temp.path())?
|
||||
.map(|entry| entry.map(|entry| entry.file_name().to_string_lossy().into_owned()))
|
||||
|
|
|
|||
Loading…
Reference in a new issue