Skip to content

Stop bundle specs leaking Tap and Cask doubles - #24267

Merged
MikeMcQuaid merged 1 commit into
mainfrom
bundle-tap-spec-reset
Oct 15, 2026
Merged

MikeMcQuaid merged 1 commit into
mainfrom
bundle-tap-spec-reset

Conversation

@p-linnane

@p-linnane p-linnane commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Homebrew::Bundle::Tap.taps and Homebrew::Bundle::Cask.casks memoise whatever Tap.select and Cask::Caskroom.casks return, so the instance_doubles that tap_spec and dumper_spec stub into them survive their example and the Installer.install! example in npm_spec fails with rspec-mocks' "leaked into another example" error whenever a dumper example ran first in the same process, as tests (no Sorbet) has been doing on main. Reset the memoised state after each of those examples; brew tests --no-parallel --only=bundle/tap,bundle/npm --seed=1 reproduces the failure before this change and passes after it.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Claude Code (Mythos 5.1) traced the leak, made the change and verified it red then green with brew tests --no-parallel --only=bundle/tap,bundle/npm --seed=1 and brew lgtm --online. I reviewed the diff.


Summary by CodeRabbit

  • Tests
    • Test cases now clear cached state between runs, helping ensure each example starts independently. This makes the test suite less susceptible to results being affected by state left behind by earlier examples. No user-facing functionality or behaviour is changed.

- `Homebrew::Bundle::Tap.taps` and `Homebrew::Bundle::Cask.casks`
  memoise whatever `Tap.select` and `Cask::Caskroom.casks` return, so
  the `instance_double`s stubbed in `tap_spec` and `dumper_spec`
  survived into later examples.
- `npm_spec`'s `Installer.install!` example then hit rspec-mocks'
  "leaked into another example" error whenever a dumper example ran
  first in the same process, failing random test orders.

Signed-off-by: Patrick Linnane <patrick@linnane.io>
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8c8b51cc-3769-4dde-aa9c-e49fe154166e
📥 Commits

Reviewing files that changed from the base of the PR and between 9bd5746 and 86dfebb.

📒 Files selected for processing: 2
  • Library/Homebrew/test/bundle/dumper_spec.rb
  • Library/Homebrew/test/bundle/tap_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

⏰ Context from checks skipped due to timeout: 19
  • GitHub Check: docker (arm64 Ubuntu 24.04)
  • GitHub Check: docker (x86_64 Ubuntu 24.04)
  • GitHub Check: docker (arm64 Ubuntu 26.04)
  • GitHub Check: docker (x86_64 Ubuntu 26.04)
  • GitHub Check: tests (Linux, 2/2)
  • GitHub Check: tests (macOS, 1/2)
  • GitHub Check: tests (online, 1/2)
  • GitHub Check: tests (no Sorbet)
  • GitHub Check: tests (macOS, 2/2)
  • GitHub Check: tests (load-only macOS)
  • GitHub Check: tests (generic OS, 2/2)
  • GitHub Check: tests (load-only Linux)
  • GitHub Check: tests (online, 2/2)
  • GitHub Check: tests (Linux, 1/2)
  • GitHub Check: tests (generic OS, 1/2)
  • GitHub Check: syntax
  • GitHub Check: workflow_syntax
  • GitHub Check: Analyze
  • GitHub Check: docs
🔇 Additional comments: 2
Library/Homebrew/test/bundle/dumper_spec.rb: 1

50-54: LGTM!

Library/Homebrew/test/bundle/tap_spec.rb: 1

9-12: LGTM!

📝 Walkthrough

The bundle dumper and tap specs now reset memoised components after each example.

Changes: Bundle spec teardown

Layer / File(s) Summary
Reset bundle components after examples
Library/Homebrew/test/bundle/dumper_spec.rb, Library/Homebrew/test/bundle/tap_spec.rb
The dumper spec resets Homebrew::Bundle::Tap and Homebrew::Bundle::Cask after each example. The tap spec resets Homebrew::Bundle::Tap after each example.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 86dfe

The changes add scoped cleanup for memoized bundle state in the affected specs. No actionable merge risk is established by the review evidence.

### Architecture Summary

Architecture risk: 🔵 Low · up to 86dfe

The change affects 1 system.

Changed systems: Library

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — Library (service) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in Library/Homebrew/test/bundle/dumper_spec.rb: Adds an after hook that resets the Tap and Cask bundle components after each example.
  • observed — Modified behavior in Library/Homebrew/test/bundle/tap_spec.rb: Adds an example-level teardown that resets Homebrew::Bundle::Tap after each example.
Pre-merge checks: Passed 4
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarises the main change: preventing bundle specs from leaking memoised Tap and Cask doubles between examples.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Oct 15, 2026
Merged via the queue into main with commit f8d1b25 Oct 15, 2026
55 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the bundle-tap-spec-reset branch October 15, 2026 07:48
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.

2 participants