feat: add :trace import tag for logging file accesses#217
Open
Koan-Bot wants to merge 3 commits intocpanel:masterfrom
Open
feat: add :trace import tag for logging file accesses#217Koan-Bot wants to merge 3 commits intocpanel:masterfrom
Koan-Bot wants to merge 3 commits intocpanel:masterfrom
Conversation
Add a trace mode that logs all unmocked file access operations to STDERR,
helping developers discover which files their code touches during tests.
use Test::MockFile qw< :trace >;
use Test::MockFile qw< :trace :nostrict >;
The trace hook is installed as an internal hook before _strict_mode_violation,
so it logs the access even when strict mode will subsequently die.
Also adds :nostrict as a tag-style alias for the existing nostrict import.
Closes cpanel#9
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
$TRACE_ENABLED, @_internal_access_hooks, and @_public_access_hooks were declared at line ~1657 but referenced at line ~627 in import(). Perl compilation fails because my-declared variables are only visible from the point of declaration onwards. Move them before import(). Fixes CI compilation error: Global symbol "$TRACE_ENABLED" requires explicit package name Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
Failure from CI |
Contributor
|
@Koan-Bot rebase |
Contributor
Author
Rebase: feat: add :trace import tag for logging file accessesBranch Actions
Automated by Kōan |
atoomic
approved these changes
Feb 24, 2026
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
Adds a
:traceimport tag that installs a built-in file access hook logging all unmocked file operations to STDERR. This helps developers discover which files their code touches during tests, so they know what to mock.Fixes #9
Changes
:trace(andtrace) import tag that enables trace mode[trace] open('/path') at file.pl line Nto STDERR for every unmocked file operation_strict_mode_violationso it fires even when strict mode will die:nostrictas a tag-style alias fornostrict(as suggested in the issue)print STDERRinstead ofwarnto avoid triggeringTest2::Plugin::NoWarningst/trace.tcovering: trace with strict, trace with nostrict, colon and non-colon syntax, caller location in output, mocked files not traced, open tracingTest plan
t/trace.t— tests trace output via subprocess execution (tmf_test_code) verifying STDERR outputt/import.t— existing import tests should still pass (no behavioral change to existing tags)Generated by Kōan /fix