Tests: read-only fixture test checks it caught its own panic

The test caught any panic from its closure, so a failed set_permissions
would also pass it while the file was still writable. It now asserts
the file is read-only before its panic and checks the caught payload is
that panic's message.
This commit is contained in:
dotCooCoo committed 2026-12-01 23:53:39 -08:00
1 parent 615d35f878
commit 8c6ce6d5c9
1 file changed
+3 -1
+3 -1
View File
@@ -1254,9 +1254,11 @@ mod tests {
let mut perms = std::fs::metadata(&file).unwrap().permissions();
perms.set_readonly(true);
std::fs::set_permissions(&file, perms).unwrap();
assert!(std::fs::metadata(&file).unwrap().permissions().readonly(), "the fixture is read-only");
panic!("a failed assertion");
});
assert!(failed.is_err());
let payload = failed.err().unwrap_or_else(|| panic!("the closure did not panic"));
assert_eq!(payload.downcast_ref::<&str>(), Some(&"a failed assertion"), "the test's own panic, not a setup failure");
assert!(!base.exists(), "{} is left", base.display());
}