Skip to content

Commit eca1e7a

Browse files
mikolalysenkoclaude
andcommitted
test: fix Windows-only file_hash directory-rejection assertion
`File::open` on a directory fails outright on Windows (different OS error kind), whereas on Unix it opens and the is_file() guard rejects it with InvalidInput. The production code rejects directories on both platforms; only pin the specific InvalidInput kind off-Windows. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c536ffb commit eca1e7a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

crates/socket-patch-core/src/patch/file_hash.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ mod tests {
109109

110110
let result = compute_file_git_sha256(dir.path()).await;
111111
let err = result.expect_err("hashing a directory must error");
112+
113+
// On Unix a directory opens successfully and the `is_file` guard
114+
// rejects it with `InvalidInput`. On Windows `File::open` on a
115+
// directory fails at the open call itself (a different OS error kind),
116+
// so we only pin the specific kind off-Windows. Either way the
117+
// contract that matters holds: it errors and never hashes.
118+
#[cfg(not(windows))]
112119
assert_eq!(err.kind(), std::io::ErrorKind::InvalidInput);
113120

114121
// It must specifically NOT have returned the empty-blob hash.

0 commit comments

Comments
 (0)