feat: add text/binary options to stat_as_* for -T/-B mock support#107
Draft
Koan-Bot wants to merge 2 commits into
Draft
feat: add text/binary options to stat_as_* for -T/-B mock support#107Koan-Bot wants to merge 2 commits into
Koan-Bot wants to merge 2 commits into
Conversation
…port
When using mock_all_from_stat(), -T and -B checks rely on Perl's
content-based heuristic which cannot work for files that don't exist
on disk. This adds text/binary options to all stat_as_* helpers so
users can control -T/-B results declaratively:
return stat_as_file( size => 100, text => 1 ); # -T true, -B false
return stat_as_file( size => 200, binary => 1 ); # -T false, -B true
Specifying one option infers the other (they are complementary).
When neither is given, behavior is unchanged (falls back to heuristic).
Implementation uses a save/restore pattern for the metadata side-channel,
consistent with existing re-entrancy handling in _check_from_stat.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Older perldocker/perl-tester images (5.10-5.22) no longer ship cpm pre-installed, causing CI failures on all PR branches. Fall back to cpanm --installdeps when cpm is not found. 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.
What
Add
textandbinaryoptions tostat_as_*helpers so-Tand-Breturn correct results when usingmock_all_from_stat().Why
Documented limitation:
-Tand-Brely on content heuristics that can't work for mocked files that don't exist on disk. Users had to mock these operators separately from their stat callback, fragmenting the mock setup. This feature lets users declare text/binary intent inline.How
_stat_for()extractstext/binaryoptions before the stat array is built and sets a package-level metadata variable_check_from_stat()saves/restores this metadata (re-entrancy safe) and passes it to the-T/-Bdispatch handlersTesting
🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 221 insertions(+), 5 deletions(-)
Code scan: clean
Tests: passed (0 Tests)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline