feat: add file_passthrough() for strict-mode-compatible real FS access#280
Draft
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
Draft
feat: add file_passthrough() for strict-mode-compatible real FS access#280Koan-Bot wants to merge 1 commit intocpanel:masterfrom
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
Conversation
…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>
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