Enable strict typing in Homebrew::TestBot (take 3)#21576
Open
Enable strict typing in Homebrew::TestBot (take 3)#21576
Conversation
This reverts commit 1439708.
Fix two runtime type errors found in CI after the initial strict typing PR: 1. `Test#test` arguments parameter: Accept `T.any(String, Pathname)` and convert to strings via `.map(&:to_s)` before passing to `Step.new`. Callers like `TestCleanup` pass `repository` (a `Pathname`) directly. 2. `BottlesFetch#fetch_bottles!` tag parameter: Accept `Utils::Bottles::Tag` (what `collector.tags` actually returns) instead of `Symbol`.
c67c011 to
b93074b
Compare
Test through public run! interfaces where practical (BottlesFetch, CleanupAfter); use send for deeply internal methods without a reasonable public entry point.
b93074b to
c8b2f7a
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Reapplies Sorbet typed: strict across the Homebrew::TestBot implementation, addressing previously observed runtime type mismatches and adding regression specs to keep TestBot’s strict typing stable over time.
Changes:
- Switches multiple
test_bot/*components totyped: strict, adding signatures and type-safe coercions (notablyPathname→Stringfor command arguments). - Aligns bottle tag typing with runtime (
Utils::Bottles::Tag) and tightens boolean return types to satisfy strict typing. - Adds/updates RSpec coverage for key strict-typing regressions (Test runner helpers, bottles fetch tags, REXML/JUnit, portable ruby boolean returns, artifact cache hash access).
Reviewed changes
Copilot reviewed 22 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Library/Homebrew/test_bot/test_runner.rbi | Removes obsolete RBI stub for TestRunner. |
| Library/Homebrew/test_bot/test_runner.rb | Converts to typed: strict and adds typed orchestration for TestBot runs and output artifacts. |
| Library/Homebrew/test_bot/test_formulae.rbi | Removes obsolete RBI stub for TestFormulae. |
| Library/Homebrew/test_bot/test_formulae.rb | Adds strict signatures and type fixes for artifact handling, git operations, and cleanup helpers. |
| Library/Homebrew/test_bot/test_cleanup.rb | Adds strict signatures and coerces repository paths to String for typed helpers/system calls. |
| Library/Homebrew/test_bot/test.rb | Adds strict signatures and coerces splat command args (incl. Pathname) to String for Step. |
| Library/Homebrew/test_bot/tap_syntax.rb | Adds strict signatures and narrows tap usage for typed access. |
| Library/Homebrew/test_bot/step.rb | Adds strict signatures and type assertions for command execution, timing, and GitHub Actions annotations. |
| Library/Homebrew/test_bot/setup.rb | Adds strict signature for run!. |
| Library/Homebrew/test_bot/junit.rb | Adds strict typing and ensures REXML is required before use. |
| Library/Homebrew/test_bot/formulae_detect.rb | Adds strict typing and refines tap/git interactions for formula detection. |
| Library/Homebrew/test_bot/formulae_dependents.rb | Adds strict typing and fixes dependent skipping/recording to use formula names. |
| Library/Homebrew/test_bot/formulae.rb | Adds strict typing and boolean return fixes around portable ruby and local bottle verification. |
| Library/Homebrew/test_bot/cleanup_before.rb | Adds strict signature for run!. |
| Library/Homebrew/test_bot/cleanup_after.rb | Adds strict signature for run! and pkill helper. |
| Library/Homebrew/test_bot/bottles_fetch.rb | Adds strict typing and switches bottle tag typing to Utils::Bottles::Tag. |
| Library/Homebrew/test_bot.rb | Marks TestBot entrypoint as typed: strict and adds signatures for helpers. |
| Library/Homebrew/test/test_bot/test_spec.rb | Adds regression spec for Pathname→String coercion in Test#test. |
| Library/Homebrew/test/test_bot/test_formulae_spec.rb | Adds regression spec for artifact download hash access keyed by new SHAs. |
| Library/Homebrew/test/test_bot/test_cleanup_spec.rb | Adds regression spec ensuring cleanup helpers receive String repository paths. |
| Library/Homebrew/test/test_bot/setup_spec.rb | Updates spec to use Homebrew::Cmd::TestBotCmd::Args and correct require. |
| Library/Homebrew/test/test_bot/junit_spec.rb | Adds regression spec ensuring REXML is loaded and JUnit XML generation works. |
| Library/Homebrew/test/test_bot/formulae_spec.rb | Adds regression specs for strict boolean returns in Formulae helpers. |
| Library/Homebrew/test/test_bot/bottles_fetch_spec.rb | Adds regression spec ensuring Tag objects are accepted and used in fetch commands. |
Files not reviewed (2)
- Library/Homebrew/test_bot/test_formulae.rbi: Language not supported
- Library/Homebrew/test_bot/test_runner.rbi: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gniumg-source
added a commit
to gniumg-source/brew
that referenced
this pull request
Feb 18, 2026
gniumg-source
added a commit
to gniumg-source/brew
that referenced
this pull request
Feb 18, 2026
Closed
MikeMcQuaid
approved these changes
Feb 22, 2026
Member
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Looks good, thanks!
@Homebrew/maintainers let's fix forward when this gets merged please 🙇🏻
Member
|
@dduugg Merge where you're ideally gonna be around for a few hours to help debug any issues! |
SMillerDev
approved these changes
Feb 22, 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.
brew lgtm(style, typechecking and tests) with your changes locally?AI was used to reapply the original strict typing PR, identify the two runtime type errors from the revert, implement fixes, and write regression specs. All changes were verified locally with
brew typecheck,brew style --fix --changed, andbrew testsfor each affected spec file.What does this PR do?
Reapplies #21539 (reverted in #21549) to enable
typed: strictacross allHomebrew::TestBotfiles, with fixes for the two Sorbet runtime type errors that caused the revert:Test#testPathname handling: Thetestmethod now acceptsT.any(String, Pathname)for its splat arguments and converts them to strings via.map(&:to_s)before forwarding toStep.new. This fixes theTypeErrorwhen callers likeTestCleanuppassPathnameobjects (e.g.repository).BottlesFetch#fetch_bottles!tag type:fetch_bottles!andformulae_by_tagnow useUtils::Bottles::Taginstead ofSymbol, matching whatbottle_specification.collector.tagsactually returns at runtime.Additional type fixes included in the reapplied commit:
Formulae#testing_portable_ruby?returnsfalse(notnil) via!!whentapis nilFormulae#verify_local_bottlesreturnsfalse(not barereturn) for the portable ruby early exitFormulaeDependents#install_dependentpassesdependent.name(String) toskipped, notdependent(Formula)Regression specs added
Tests use public
run!interfaces where practical;sendis used only for deeply internal methods without a reasonable public entry point.bottles_fetch_spec.rb— exercisesBottlesFetch#run!to verifyUtils::Bottles::Tagis acceptedtest_cleanup_spec.rb— exercisesCleanupAfter#run!to verifycleanup_sharedpassesStringto helper methodstest_spec.rb— verifiesPathnamearguments are converted to stringsformulae_spec.rb— verifiestesting_portable_ruby?andverify_local_bottlesreturnT::Booleanjunit_spec.rb— verifies REXML loads correctly (therequirewas moved toinitialize)test_formulae_spec.rb— verifiesdownload_artifacts_from_previous_run!hash accesssetup_spec.rb— updated to useHomebrew::Cmd::TestBotCmd::Args