Skip to content

Reduce platform-gated test specs#22079

Merged
MikeMcQuaid merged 1 commit intomainfrom
reducing-platform-specific-test-decorators-with-si
Apr 24, 2026
Merged

Reduce platform-gated test specs#22079
MikeMcQuaid merged 1 commit intomainfrom
reducing-platform-specific-test-decorators-with-si

Conversation

@MikeMcQuaid
Copy link
Copy Markdown
Member

  • replace :needs_linux and :needs_macos where Homebrew::SimulateSystem already drives the behaviour under test
  • exercise launchctl and systemctl discovery through temporary PATH entries so service specs run on both platforms
  • add reset_launchctl! so the tests reset cached state without reaching into instance variables

  • 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. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes. Non-maintainers may only have one AI-assisted/generated PR open at a time.

OpenAI Codex with manual review and tweaks.


- replace `:needs_linux` and `:needs_macos` where
  `Homebrew::SimulateSystem` already drives the behaviour under test
- exercise `launchctl` and `systemctl` discovery through temporary
  `PATH` entries so service specs run on both platforms
- add `reset_launchctl!` so the tests reset cached state without
  reaching into instance variables
Copilot AI review requested due to automatic review settings April 24, 2026 15:42
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 reduces platform-gated specs by using Homebrew::SimulateSystem and temporary PATH shims to make the relevant tests exercise discovery logic on both macOS and Linux, while adding a small reset hook to avoid poking cached state via instance variables.

Changes:

  • Replace :needs_linux/:needs_macos in several specs with Homebrew::SimulateSystem.with(...).
  • Update services-related specs to discover launchctl/systemctl via temporary executables in PATH, enabling cross-platform execution.
  • Add Homebrew::Services::System.reset_launchctl! to reset cached launchctl discovery between tests.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Library/Homebrew/test/software_spec_spec.rb Removes platform gating by simulating OS versions and updating expectations around uses_from_macos.
Library/Homebrew/test/services/system_spec.rb Makes launchctl/systemctl discovery tests portable via temporary PATH executables and cache resets.
Library/Homebrew/test/services/system/systemctl_spec.rb Reworks .executable spec to use a temporary systemctl on PATH instead of platform gating.
Library/Homebrew/test/services/cli_spec.rb Exercises systemd_load/launchctl_load by running temporary shim executables and asserting captured arguments.
Library/Homebrew/test/service_spec.rb Replaces platform-gated service command selection specs with Homebrew::SimulateSystem contexts.
Library/Homebrew/services/system.rb Adds reset_launchctl! to reset cached launchctl path.

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

@MikeMcQuaid MikeMcQuaid enabled auto-merge April 24, 2026 15:54
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Apr 24, 2026
Merged via the queue into main with commit 257321b Apr 24, 2026
40 checks passed
@MikeMcQuaid MikeMcQuaid deleted the reducing-platform-specific-test-decorators-with-si branch April 24, 2026 20:10
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