Skip to content

feat: add guard variants for mock_stat and mock_all_from_stat#103

Draft
Koan-Bot wants to merge 2 commits into
cpan-authors:mainfrom
Koan-Bot:koan.atoomic/feat-guard-variants
Draft

feat: add guard variants for mock_stat and mock_all_from_stat#103
Koan-Bot wants to merge 2 commits into
cpan-authors:mainfrom
Koan-Bot:koan.atoomic/feat-guard-variants

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

@Koan-Bot Koan-Bot commented May 6, 2026

What

Adds scope-guard variants for the three remaining mock functions that lacked them.

Why

mock_file_check_guard() exists but only covers single-check mocking. The most common usage pattern — mock_all_from_stat — had no guard option, forcing manual cleanup calls that break test isolation when tests die or fail early.

How

Three new functions, all returning the existing Overload::FileCheck::Guard object:

  • mock_stat_guard(CODE) — guards stat/lstat mocks
  • mock_all_file_checks_guard(CODE) — guards all -X check mocks
  • mock_all_from_stat_guard(CODE) — guards everything (checks + stat/lstat)

Each captures the set of mocked ops at creation time and unmocks them on scope exit.

Testing

  • New t/guard-variants.t with 9 subtests covering scope cleanup, cancel, die-safety, and sequential guards
  • Full test suite passes (all existing tests unaffected)

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 263 insertions(+), 2 deletions(-)

Code scan: clean

Tests: passed (0 Tests)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Koan-Bot and others added 2 commits May 6, 2026 04:51
…l_from_stat

The existing mock_file_check_guard() only covers single-check mocking.
Test suites that use mock_stat or mock_all_from_stat (the most common
pattern) had no scope-guard option, forcing manual unmock_stat() or
unmock_all_file_checks() calls that break test isolation on die/failure.

New functions:
- mock_stat_guard(CODE) — guards stat/lstat mocks
- mock_all_file_checks_guard(CODE) — guards all -X check mocks
- mock_all_from_stat_guard(CODE) — guards everything (checks + stat/lstat)

All return the existing Overload::FileCheck::Guard object, supporting
cancel() and automatic cleanup on scope exit or die.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant