Skip to content

test_runner_formula: treat versioned macOS deps as macOS-only#22420

Merged
MikeMcQuaid merged 5 commits into
Homebrew:mainfrom
ivan-digital:fix-macos-only-versioned
May 26, 2026
Merged

test_runner_formula: treat versioned macOS deps as macOS-only#22420
MikeMcQuaid merged 5 commits into
Homebrew:mainfrom
ivan-digital:fix-macos-only-versioned

Conversation

@ivan-digital
Copy link
Copy Markdown
Contributor

@ivan-digital ivan-digital commented May 26, 2026

TestRunnerFormula#macos_only? currently returns true only for an unversioned depends_on :macos. With #22199 the Homebrew/OSDependsOn cop now flags the bare form as redundant whenever a versioned depends_on macos: is also present, so the two forms are mutually exclusive in formulae. After that change, a new macOS-only formula whose canonical form is just depends_on macos: :sequoia reports macos_only? == false, so brew determine-test-runners schedules Linux ARM64 runners that then fail (e.g. swift: No such file or directory).

This drops the !r.version_specified? clause so any MacOSRequirement -- versioned or not -- counts as macOS-only. Linux cannot satisfy a versioned MacOSRequirement either, so the broader behaviour is consistent.

Reproducer: Homebrew/homebrew-core#282141 (a new macOS-only formula with depends_on macos: :sequoia only). The existing fix campaign in homebrew-core#282148 did not surface this because all affected formulae already had bottles, so setup_runners was skipped.

Spec updates: needs_modern_compiler.macos_only? flips from false to true; needs_modern_compiler.linux_compatible? flips from true to false. No other expectations change.


  • 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? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR.

Diagnosis and patch drafted with Claude. The conflict between OSDependsOn and macos_only? was identified while investigating a CI failure on a new macOS-only formula; the one-line dispatcher fix and spec updates were verified locally with brew tests --only=test_runner_formula, brew style, and brew typecheck.


@github-actions
Copy link
Copy Markdown

Thanks for your pull request. This has been closed because it appears to use an incomplete or outdated pull request template.

Please edit the pull request body to fill in the current pull request template. This workflow will reopen the pull request automatically once the template is complete.

A formula with only `depends_on macos: :sequoia` (no bare
`depends_on :macos`) is still macOS-only -- a versioned `MacOSRequirement`
cannot be satisfied on Linux. Before this change, `macos_only?` only
returned true for the unversioned form, so new macOS-only formulae using
only the versioned form would dispatch Linux ARM64 runners.

The `Homebrew/OSDependsOn` cop added in Homebrew#22199 flags the bare
`depends_on :macos` as redundant whenever a versioned `depends_on macos:`
is present, so the two forms are now mutually exclusive in practice.
This change keeps the dispatcher consistent with the cop's expectation.
@ivan-digital ivan-digital force-pushed the fix-macos-only-versioned branch from 931a965 to bbfb1a2 Compare May 26, 2026 07:07
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! We have new DSLs for this that we missed using here, can you see if this works instead?

Comment thread Library/Homebrew/test_runner_formula.rb Outdated
Comment thread Library/Homebrew/test_runner_formula.rb Outdated
Comment thread Library/Homebrew/test_runner_formula.rb Outdated
Comment thread Library/Homebrew/test_runner_formula.rb Outdated
ivan-digital and others added 4 commits May 26, 2026 10:00
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
@ivan-digital
Copy link
Copy Markdown
Contributor Author

Thanks! We have new DSLs for this that we missed using here, can you see if this works instead?

@MikeMcQuaid seems all work. I accepted your suggestions.

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 May 26, 2026
Merged via the queue into Homebrew:main with commit 0b7a7c7 May 26, 2026
36 checks passed
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