Skip to content

test: deprecate return false in test#21296

Merged
MikeMcQuaid merged 1 commit intomainfrom
odeprecate-test-false
Dec 21, 2025
Merged

test: deprecate return false in test#21296
MikeMcQuaid merged 1 commit intomainfrom
odeprecate-test-false

Conversation

@cho-m
Copy link
Copy Markdown
Member

@cho-m cho-m commented Dec 21, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

Replacement for #21291 to allow odeprecate cycle.

Using BasicObject as we have no control over what a formula test block returns and we need something that supports ==.

Copilot AI review requested due to automatic review settings December 21, 2025 16:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR deprecates the use of return false to indicate test failure in Homebrew formula tests, encouraging the use of explicit exceptions instead. This is part of a gradual migration (allowing for an odeprecate cycle) to phase out this legacy behavior.

  • Adds deprecation warning when a test returns false, guiding users to use raise instead
  • Updates type signatures from T.nilable(T::Boolean) or T.untyped to BasicObject to support the transition period
  • Includes TODO comments marking where code can be simplified once the deprecation cycle is complete

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Library/Homebrew/test.rb Adds detection and deprecation warning for return false in tests, along with TODOs for future cleanup
Library/Homebrew/formula.rb Updates type signatures for run_test, test methods to use BasicObject instead of boolean types, with TODOs for reverting to void after deprecation cycle
Library/Homebrew/debrew.rb Updates type signature for the test method override to match the new BasicObject return type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Alternatives like `raise` are more informative than `return false`.
Dropping this simplifies typing where we have to allow arbitrary return
types just so we can handle FalseClass.
@cho-m cho-m force-pushed the odeprecate-test-false branch from f45666e to 53f0e46 Compare December 21, 2025 16:56
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

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 Dec 21, 2025
Merged via the queue into main with commit 330cecb Dec 21, 2025
37 checks passed
@MikeMcQuaid MikeMcQuaid deleted the odeprecate-test-false branch December 21, 2025 17:52
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.

3 participants