Skip to content

Commit d7deed9

Browse files
mikolalysenkoclaude
andcommitted
fix(test): make manifest-unreadable list test cross-platform
`manifest_path_through_regular_file_reports_unreadable_via_binary` nested the manifest under a regular file (`<file>/manifest.json`), assuming the OS rejects the read with a non-absence error. That holds on Unix (ENOTDIR) but NOT on Windows, where traversing through a file is `ERROR_PATH_NOT_FOUND` (NotFound) — legitimately classified as `manifest_not_found`, failing the assertion on windows-latest. Point the manifest path at a directory instead: reading it fails with a non-NotFound error on every platform (Unix `IsADirectory`, Windows `PermissionDenied`), so the "present-but-unreadable → manifest_unreadable" contract is exercised portably. Renamed accordingly. This was masked on the first push: cargo test is fail-fast and the Windows run aborted at this binary (sorts before the now-fixed golang/output tests). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent dfe7bbc commit d7deed9

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

crates/socket-patch-cli/tests/cli_parse_list.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -392,21 +392,23 @@ fn missing_manifest_under_valid_cwd_reports_manifest_not_found_via_binary() {
392392
}
393393

394394
#[test]
395-
fn manifest_path_through_regular_file_reports_unreadable_via_binary() {
396-
// A genuine I/O error reaching the manifest must be `manifest_unreadable`,
397-
// never `manifest_not_found`. Here the manifest path is nested *under a
398-
// regular file* (`<file>/manifest.json`), so the OS rejects the read with
399-
// ENOTDIR — an I/O error, not file-absence.
395+
fn manifest_path_is_existing_directory_reports_unreadable_via_binary() {
396+
// A genuine I/O error reaching an *existing* path must be
397+
// `manifest_unreadable`, never `manifest_not_found`. Here the manifest path
398+
// points at a directory, so the read fails with a non-absence I/O error
399+
// (Unix `IsADirectory` / Windows `PermissionDenied`) — present, but
400+
// unreadable. (We use a directory rather than a `<regular-file>/manifest`
401+
// path because the latter is `ENOTDIR` on Unix but a NotFound-class error
402+
// on Windows, where traversing through a file is legitimately "path not
403+
// found"; a directory yields a non-NotFound error on every platform.)
400404
//
401405
// Regression: `run()` used to stat the path with `tokio::fs::metadata`
402-
// first and treat ANY stat failure as `manifest_not_found`, so this case
403-
// (and an unreadable parent dir, etc.) was misreported as a missing file.
404-
// Removing that pre-check lets `read_manifest`'s I/O error classify it
405-
// correctly.
406+
// first and treat ANY stat failure as `manifest_not_found`, masking real
407+
// I/O errors. Removing that pre-check lets `read_manifest`'s I/O error
408+
// classify it correctly.
406409
let tmp = tempfile::tempdir().unwrap();
407-
let blocker = tmp.path().join("not-a-dir");
408-
std::fs::write(&blocker, b"i am a regular file").unwrap();
409-
let manifest_path = blocker.join("manifest.json");
410+
let manifest_path = tmp.path().join("manifest-is-a-dir");
411+
std::fs::create_dir(&manifest_path).unwrap();
410412

411413
let out = run_list_binary(
412414
tmp.path(),

0 commit comments

Comments
 (0)