Add brew tests --load-only and break the install require cycle - #23642
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request strengthens Homebrew’s test harness by making circular-require warnings fail fast and by adding a new brew tests --load-only mode to load specs in isolation, while also eliminating an existing install-related require cycle on macOS.
Changes:
- Add
brew tests --load-onlyto load selected spec files independently (via per-file RSpec processes) without running examples. - Introduce
Warnings.fail_onand register circular-require warnings as fatal in the RSpecspec_helper, replacing prior per-spec suppression. - Break the
install/reinstallrequire cycle by deferringrequire "install"to the specific macOSpkgconfmismatch branch.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| manpages/brew.1 | Documents the new --load-only option for brew tests. |
| Library/Homebrew/warnings.rb | Adds fatal-warning support via Warnings.fail_on and enforces it inside the Warning.warn hook. |
| Library/Homebrew/test/warnings_spec.rb | Adds unit tests covering fatal-warning behavior and scoping/restoration semantics. |
| Library/Homebrew/test/spec_helper.rb | Makes circular-require warnings fatal for the test suite by default. |
| Library/Homebrew/test/os/mac/reinstall_spec.rb | Updates macOS reinstall specs to explicitly require "install" now that it’s deferred in implementation. |
| Library/Homebrew/test/formula_installer_spec.rb | Removes circular-require suppression wrapper around require "install". |
| Library/Homebrew/test/dev-cmd/tests_spec.rb | Adds coverage for brew tests --load-only argument construction and line-qualified behavior. |
| Library/Homebrew/test/cmd/shared_examples/reinstall_pkgconf_if_needed.rb | Ensures shared examples explicitly require "install" where Homebrew::Install is referenced. |
| Library/Homebrew/test/cmd/install_spec.rb | Removes circular-require suppression wrapper around require "install". |
| Library/Homebrew/test/cask/installer_spec.rb | Removes circular-require suppression wrapper around require "install". |
| Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/tests.rbi | Adds Sorbet RBI for the new load_only? argument helper. |
| Library/Homebrew/extend/os/mac/reinstall.rb | Defers require "install" into reinstall_pkgconf_if_needed! to break the cycle. |
| Library/Homebrew/dev-cmd/tests.rb | Implements --load-only (dry-run + per-file process loading) in the brew tests dev command. |
| Library/Homebrew/.rspec_parallel | Skips runtime/JUnit/GitHub formatters on --dry-run to keep load-only runs lightweight. |
| docs/Manpage.md | Documents the new --load-only option in the manpage source. |
| completions/zsh/_brew | Adds --load-only completion/help text for zsh. |
| completions/fish/brew.fish | Adds --load-only completion/help text for fish. |
| completions/bash/brew | Adds --load-only completion for bash. |
| .github/workflows/tests.yml | Adds a CI step to run brew tests --load-only on Linux and macOS jobs. |
Files not reviewed (1)
- Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/tests.rbi: File type not supported
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
MikeMcQuaid
approved these changes
Aug 24, 2026
MikeMcQuaid
left a comment
Member
There was a problem hiding this comment.
Thanks, nice idea! Just want to tweak when it's run.
Signed-off-by: Patrick Linnane <patrick@linnane.io>
p-linnane
force-pushed
the
tests-load-only
branch
from
August 24, 2026 18:38
4ff2612 to
3909de8
Compare
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.
brew testsemits a Ruby 4 circular require warning while loading the specs:loading in progress, circular require considered harmful - Library/Homebrew/install.rb. It was suppressed withWarnings.ignorewrappers in four spec files, which hid the warning without removing the cycle.The cycle is
install->upgrade->reinstall->extend/os/reinstall->extend/os/mac/reinstall->install.Homebrew::Installis only used on the branch that reinstalls pkgconf after a macOS SDK mismatch, so deferring the require intoreinstall_pkgconf_if_needed!breaks the cycle and lets the four suppressions go.Warnings.fail_onraises on a matching warning andspec_helperregisters the circular-require pattern, so a new cycle fails the suite instead of scrolling past. An explicitWarnings.ignorestill takes precedence, andfail_onalso accepts a block for thread-scoped use.brew tests --load-onlyloads every selected spec in its own RSpec process without running examples, which is what surfaces this class of cycle. It reuses the command's existing OS filtering and selection. The macOS and Linux jobs run it last, so a timeout can only truncate the supplemental check, and.rspec_parallelskips the runtime log, JUnit and GitHub formatters on dry runs.Reproduce on
main:brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Code (Opus 5) drafted the implementation and tests; I reviewed the diff, verified the warning reproduces before the change and is absent after, and ran
brew lgtm --onlineplus targeted specs on macOS and Linux.