Skip to content

Comments

fix: glob now falls back to real filesystem for unmocked paths (#158)#197

Merged
toddr merged 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/fix-issue-158
Feb 25, 2026
Merged

fix: glob now falls back to real filesystem for unmocked paths (#158)#197
toddr merged 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/fix-issue-158

Conversation

@atoomic
Copy link
Contributor

@atoomic atoomic commented Feb 20, 2026

The __glob override only searched %files_being_mocked via Text::Glob, never falling back to CORE::glob for real filesystem results. This caused glob() to return empty results for real files on disk when Test::MockFile was loaded (even in nostrict mode with nothing mocked).

Now __glob merges real CORE::glob results with mocked file matches, skipping any paths that are actively mocked (mock takes precedence). Results are sorted to maintain glob's alphabetical order contract.

Closes #158

@Koan-Bot Koan-Bot force-pushed the koan.atoomic/fix-issue-158 branch from 1b08cf2 to 2bb8e2d Compare February 21, 2026 14:12
@Koan-Bot
Copy link
Contributor

Fixed CI failure: t/globbing.t was dying because _real_file_access_hook('glob', ...) triggered _strict_mode_violation, and 'glob' isn't registered in file_arg_position_for_command → croak.

Fix: The CORE::glob fallback is now gated behind !is_strict_mode(). In strict mode, glob only returns mocked files (original behavior). In nostrict mode, it merges real filesystem results — which is the actual #158 use case.

Removed the _real_file_access_hook call entirely since we handle the strict/nostrict branching explicitly.

@Koan-Bot Koan-Bot force-pushed the koan.atoomic/fix-issue-158 branch from 2bb8e2d to 43e133c Compare February 23, 2026 04:49
…l#158)

The __glob override only searched %files_being_mocked via Text::Glob,
never falling back to CORE::glob for real filesystem results. This
caused glob() to return empty results for real files on disk when
Test::MockFile was loaded (even in nostrict mode with nothing mocked).

Now __glob merges real CORE::glob results with mocked file matches,
skipping any paths that are actively mocked (mock takes precedence).
Results are sorted to maintain glob's alphabetical order contract.

Closes cpanel#158

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Koan-Bot Koan-Bot force-pushed the koan.atoomic/fix-issue-158 branch from 43e133c to 4f50301 Compare February 24, 2026 21:34
@toddr toddr merged commit 830f0c0 into cpanel:master Feb 25, 2026
18 checks passed
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.

Test::MockFile corrupts glob

3 participants