Skip to content

test(cram): add test for switching cram test from directory to file - #14369

Merged
Alizter merged 1 commit into
ocaml:mainfrom
Alizter:push-soozxnsynqxs
Apr 29, 2026
Merged

Alizter merged 1 commit into
ocaml:mainfrom
Alizter:push-soozxnsynqxs

Conversation

@Alizter

@Alizter Alizter commented Apr 29, 2026 •

Copy link
Copy Markdown
Collaborator

When a directory cram test produces a diff, the .corrected path in _build is a
directory. Switching to a file cram test then fails with:
Error: rename(_build/default/mytest.t.corrected): Is a directory

Existing tests (working-directory-cram-github6575.t) only cover switching
without a diff, and promote-file-to-dir.t only covers the file-to-directory
direction. This test covers tests cover the missing cases.

Add dir-to-file-promotion.t demonstrating that switching a cram test from a
directory (mytest.t/run.t) to a file (mytest.t) after producing a diff fails
with "rename: Is a directory" due to a stale .corrected directory in _build.

Existing tests (working-directory-cram-github6575.t) only cover switching
without producing a diff, and promote-file-to-dir.t only covers file-to-dir.

Signed-off-by: Ali Caglayan <[email protected]>
@Alizter
Alizter merged commit 6f6fa42 into ocaml:main Apr 29, 2026
29 checks passed
@Alizter
Alizter deleted the push-soozxnsynqxs branch April 29, 2026 17:40
Alizter added a commit that referenced this pull request Apr 30, 2026
…ntermediate (#14371)

When a promoted target changes from a directory to a file between
builds, the
old staging path remains as a directory. Unix.rename and Io.copy_file
cannot
overwrite a directory with a file, causing "Is a directory" errors.

Fix by unlinking the staging path before writing, using rm_rf only when
it's a
directory. This handles both the Move path (cram tests, optional diffs)
and the
Copy path (non-optional diffs with directory targets).

Updates dir-to-file-promotion.t and dir-to-file-target-change.t to
reflect the
fix.

- fixes #5647
- fixes #6575
- [x] depends on #14370 
- [x] depends on #14369 
- [x] changes
@Alizter Alizter added this to the 3.24.0 milestone Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant