[codex] Use expect in integration tests (#28441)

The workspace denies `clippy::expect_used` in production. Although
`clippy.toml` allows `expect` in tests, Bazel Clippy compiles
integration-test helper code in a way that does not receive that
exemption, which encouraged verbose `unwrap_or_else(... panic!(...))`
and equivalent `match`/`let else` forms.

This allows `clippy::expect_used` once at each integration-test crate
root (including aggregated suites and test-support libraries), then
replaces manual panic-based Result and Option unwraps with
`expect`/`expect_err`. Standalone `tests/*.rs` files remain their own
crate roots. Intentional assertion and unexpected-variant panics remain
unchanged, and the production `expect_used = "deny"` lint remains in
place.

The cleanup is mechanical and net-negative in line count.
This commit is contained in:
pakrym-oai
2026-06-15 21:53:47 -07:00
committed by GitHub
parent 08901fc8e1
commit e752f7b4ae
118 changed files with 608 additions and 916 deletions
@@ -397,10 +397,7 @@ async fn file_system_copy_rejects_directory_without_recursive(
/*sandbox*/ None,
)
.await;
let error = match error {
Ok(()) => panic!("copy should fail"),
Err(error) => error,
};
let error = error.expect_err("copying a directory without recursion should fail");
assert_eq!(error.kind(), std::io::ErrorKind::InvalidInput);
assert_eq!(
error.to_string(),
@@ -585,10 +582,7 @@ async fn file_system_copy_rejects_copying_directory_into_descendant(
/*sandbox*/ None,
)
.await;
let error = match error {
Ok(()) => panic!("copy should fail"),
Err(error) => error,
};
let error = error.expect_err("copying a directory into itself should fail");
assert_eq!(error.kind(), std::io::ErrorKind::InvalidInput);
assert_eq!(
error.to_string(),
@@ -76,10 +76,7 @@ pub(crate) fn absolute_path(path: std::path::PathBuf) -> AbsolutePathBuf {
"path must be absolute: {}",
path.display()
);
match AbsolutePathBuf::try_from(path) {
Ok(path) => path,
Err(err) => panic!("path should be absolute: {err}"),
}
AbsolutePathBuf::try_from(path).expect("path should be absolute")
}
pub(crate) fn read_only_sandbox(readable_root: std::path::PathBuf) -> FileSystemSandboxContext {
@@ -1,4 +1,5 @@
#![cfg(unix)]
#![allow(clippy::expect_used)]
mod common;
@@ -842,10 +843,7 @@ async fn file_system_copy_rejects_standalone_fifo_source(
/*sandbox*/ None,
)
.await;
let error = match error {
Ok(()) => panic!("copy should fail"),
Err(error) => error,
};
let error = error.expect_err("copying a FIFO should fail");
assert_eq!(error.kind(), std::io::ErrorKind::InvalidInput);
assert_eq!(
error.to_string(),
@@ -1,4 +1,5 @@
#![cfg(windows)]
#![allow(clippy::expect_used)]
mod common;