Skip to content

Comments

feat: add rename() override for mocked files#212

Closed
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/implement-rename
Closed

feat: add rename() override for mocked files#212
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/implement-rename

Conversation

@Koan-Bot
Copy link
Contributor

Summary

Adds CORE::GLOBAL::rename override so that rename() works correctly on mocked files.

Currently, calling rename() on a mocked file bypasses the mock layer entirely and hits the real filesystem, which is both confusing and potentially destructive in tests.

Changes

  • New __rename($$) function following existing override patterns
  • Registered in file_arg_position_for_command and BEGIN block
  • Added EXDEV and ENOTEMPTY to Errno imports

Behavior

Scenario Result
Both paths unmocked Pass through to CORE::rename
Source mocked → destination Mock re-registered at new path
Overwrite existing mock Destination cleared, source takes its place
File over directory EISDIR
Directory over file ENOTDIR
Over non-empty directory ENOTEMPTY
Real → mocked cross-boundary EXDEV
Non-existent source ENOENT
Same path No-op success
Symlink source Moves symlink entry (no follow)

Tests

New t/rename.t with 10 subtests covering all scenarios above.


🤖 Generated with Claude Code

Implements CORE::GLOBAL::rename to handle mocked file renames:
- Mocked source moves to new path, preserving content
- Overwrites existing mocked destination (matching real behavior)
- Error handling: ENOENT, EISDIR, ENOTDIR, ENOTEMPTY, EXDEV
- Symlink entries rename without following (correct rename semantics)
- Same-path rename is a safe no-op
- Unmocked files pass through to CORE::rename

Includes comprehensive test suite (t/rename.t) covering all scenarios.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Koan-Bot Koan-Bot force-pushed the koan.atoomic/implement-rename branch from 03d28e4 to 527f9dd Compare February 24, 2026 07:13
@Koan-Bot
Copy link
Contributor Author

Superseded by #222 which includes both the rename override and the autovivify feature.

@Koan-Bot Koan-Bot closed this Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant