feat: add file_passthrough() for strict-mode-compatible real FS access#280
Open
Koan-Bot wants to merge 3 commits intocpanel:masterfrom
Open
feat: add file_passthrough() for strict-mode-compatible real FS access#280Koan-Bot wants to merge 3 commits intocpanel:masterfrom
Koan-Bot wants to merge 3 commits intocpanel:masterfrom
Conversation
Member
|
@Koan-Bot rebase |
Cover untested paths in FileHandle.pm WRITE and READ tied methods: syswrite: - zero-length write (len=0) returns 0, writes nothing - O_APPEND mode always appends even after seek - seek past EOF then write creates null-byte gap - float len truncated to int (2.9 → 2) - non-numeric len warns + EINVAL - negative len warns + EINVAL - empty buffer with len=0 sysread: - non-numeric len warns + returns undef + EINVAL - negative len warns + returns undef + EINVAL - float len truncated to int (3.7 → 3) - zero-length read returns 0 - undef buffer initialized to empty string - undef buffer with offset pads null bytes - write-only handle returns undef + EBADF - read at EOF returns 0 - write then read in O_RDWR mode Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract _default_mock_attrs() and _new_nonexistent_file_mock() to centralize mock object construction defaults that were duplicated across new(), _create_file_through_broken_symlink(), and _maybe_autovivify(). Changes to defaults now only need to happen in one place. Add _maybe_throw_autodie() helper that combines the check-and-throw pattern (_throw_autodie + _caller_has_autodie_for) into a single call, reducing 50 two-line boilerplate patterns to one-liners. Remove dead $set_error variable in __chown — it was declared but never set to true, so the conditional guards were always no-ops. Fix CAEATS typo in POD (now CAVEATS). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…em access Adds Test::MockFile->file_passthrough($path) which registers a path with strict mode but delegates all I/O to the real filesystem. This allows XS-based modules like DBD::SQLite that perform C-level I/O to create and use files while Perl-level checks (-f, stat, open) remain consistent under strict mode. The passthrough object adds a strict rule (allow-all for the path) and intentionally does NOT register in %files_being_mocked, so all overrides fall through to CORE::*. On scope exit (DESTROY), the strict rule is removed but the real file is not deleted. Closes cpanel#91 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5e8323a to
a69e0ba
Compare
Contributor
Author
Rebase: feat: add file_passthrough() for strict-mode-compatible real FS accessBranch Diff: 2 files changed, 210 insertions(+) Review feedback was analyzed and applied. Actions
CICI passed. Automated by Kōan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test::MockFile->file_passthrough($path)which registers a path with strict mode but delegates all I/O to the real filesystemWhy
When using Test::MockFile in strict mode, XS modules like DBD::SQLite that use C-level file operations (not Perl's
open) fail because strict mode blocks access to unmocked paths.file_passthroughadds a strict rule allowing all operations on the given path while intentionally NOT registering it in%files_being_mocked, so all overrides fall through toCORE::*.How
file_passthrough($path)creates a strict-mode rule (allow-all for exact path) and returns a blessed object%files_being_mocked, so_mock_stat,__open, etc. all fall through to real filesystemTesting
t/file_passthrough.t: object creation, real FS delegation (write/read/stat/unlink), coexistence with regular mocks, scope cleanup, input validationCloses #91
🤖 Generated with Claude Code