Commit Graph
16 Commits
Author SHA1 Message Date
Mike McQuaid 204ea7e964 Make tests use public APIs and enable their cops
- Make every statically-poked method public and call it directly,
  keeping `public_send` only for dynamically-named public methods.
- Read and write state through public `attr_*` accessors instead of
  instance variable reflection.
- Enable `Homebrew/NoSendInTests` and
  `Homebrew/NoInstanceVariableAccessInTests` now the test suite is
  clean, so neither pattern creeps back in.
- Keep rare justified disables, e.g. `Module#remove_const` is
  private core Ruby and raw memoisation state has no accessor.
2026-07-27 08:11:46 +01:00
Issy LongandBo Anderson 46d728bad9 tests: Use RSpec's described_class now Sorbet understands it
- Since https://github.com/sorbet/sorbet/commit/d9d4b57b3fde3907d739ed85d340e64f75f2a7b8
  Sorbet types `described_class` more correctly than assuming `T.untyped`.
- Switched back via having Copilot CLI (GPT 5.3 Codex) write me a
  script to change all of the `klass` references into full class names,
  and then running RuboCop's autocorrector having removed the `explicit`
  style. The explicit style was deemed too verbose in
  0c1321f1b1, hence why we went with
  `let(:klass)`.
- This is much less verbose than the full class name, while preserving
  Sorbet typing of the tests fully.
2026-06-07 00:37:41 +01:00
Issy Long 540457b88b sorbet: Use T.bind in formula blocks in tests
- Don't duplicate all of `formula.rbi` in the `rspec.rbi` shim because
  it's a terrible pattern.
- I also noticed a supposedly typechecked file
  `test/test_bot/formulae_spec.rb` that was definitely cheating through
  the use of `T.bind(self, T.untyped)` and `T.unsafe`. So, follow the
  same `T.bind(self, T.class_of(Formula))` pattern in test files to make
  sure we're getting proper type checking in `formula` blocks.
2026-06-04 23:40:59 +01:00
Issy Long 572aa16560 sorbet: A formula's url method does exist
- Even having added shims for the `formula("name")` method, Sorbet still
  didn't always recognize `url` as a valid Formula DSL method, raising
  error 7003 for method does not exist.

- My first idea to solve this was to add
  `T.bind(self, T.class_of(Formula))` to every `formula do`
  block inside `stub_formula_loader` where Sorbet was failing, but that
  was a lot of edits and it still didn't work in all cases.

- With GPT-5.3-Codex's help, I discovered that Sorbet was sometimes
  detecting `url` as being called on a Formula class (yay), but other
  times on `RSpec::Core::ExampleGroup` or `Test::Helper::Formula`, so,
  make Sorbet aware of `url` in those contexts as well. There only seem
  to be `url` calls in `formula` blocks, so this shouldn't grow too much
  more unwieldy.
2026-06-01 00:34:03 +01:00
Mike McQuaid fd9847d953 bundle: add WinGet support
- make Windows package state manageable from WSL
- use `winget` and `msstore` sources with stable IDs
- keep installer UI disabled while allowing UAC retry
- dump non-internal packages with readable names
2026-05-24 13:13:45 +01:00
Issy LongandMike McQuaid 0c1321f1b1 tests: Prefer let(:klass) { Foo } over described_class
- The "explicit" setting on the `RSpec/DescribedClass` cop is still
  enabled, because `described_class` is bad for Sorbet typing, but
  instead of applying its autocorrections to specify the full class name
  everywhere that `described_class` was used, use
  `let(:klass) { Foo }` so that the repetition per-test isn't massive in
  tests that use it a lot (say, >5 times).

- Changes made with Copilot CLI, agent mode, Claude Opus 4.7.
2026-05-22 14:32:42 +01:00
John CostaandMike McQuaid b556e4ab78 fix(bundle): don't skip tap-qualified casks on Linux when tap isn't installed yet
When a Brewfile cask comes from a tap (e.g., ublue-os/tap/vscodium-linux),
the Linux skipper's macos_only_cask? check tries to load the cask before
its tap is installed. The CaskError rescue assumed macOS-only, causing the
cask to be skipped on the first run but not the second.

Check if the cask has a tap-qualified full_name in the rescue block. If so,
don't assume macOS-only — let the normal install flow handle it after the
tap is processed.

Fixes #21992
2026-04-15 16:50:44 +01:00
Mike McQuaid 9d79093ab9 Fix supports_linux? for platform-agnostic casks
- bb22d4f required an explicit `os` stanza for
  `supports_linux?` to return true, which broke
  platform-agnostic casks like `dynamodb-local` that
  have no `on_system` blocks at all
- for casks with OS blocks, keep using `os` stanza
  presence; for platform-agnostic casks, check
  artifacts for macOS-only classes and manual
  installers (matching the Linux installer's
  `supported_artifact?` predicate)
- add `on_os_blocks_exist?` to distinguish OS-specific
  blocks from arch-only blocks so arch-only casks are
  correctly treated as platform-agnostic
- add regression tests for manual installer cask and
  platform-agnostic cask in `bundle/skipper_spec`
2026-04-07 14:13:22 +01:00
Mike McQuaid bb22d4fbbb Make Linux cask requirements explicit
- stop surfacing casks on Linux unless `supports_linux?`
  says they are safe to advertise, so `search` and
  `bundle` stay conservative about unknown support
- move cask platform output into a `Requirements`
  section so `brew info` explains macOS-only casks the
  same way on macOS and Linux
- reuse `requires macOS` in `brew bundle` for both
  `brew` and `cask` entries so platform warnings use the
  same language across commands
- cover the shared policy with regressions around
  `search`, `cask/info`, `bundle/skipper`, and
  `Cask#supports_linux?`
2026-04-05 13:39:05 +01:00
Issy Long f3fb592638 sorbet: Make tests typed: false
- Now that we've enabled `--experimental-rspec-mode` [1], let's start
  using Sorbet in tests at its basic `typed: false` level for now.
- This will ease the migration to `typed: true` of any or all tests we
  want to do in the future.

[1]: https://github.com/Homebrew/brew/pull/21742
2026-03-29 16:37:52 +01:00
Douglas Eichelberger 07b919c4c9 Remove OpenStruct, replace with test doubles 2026-02-04 16:51:14 -08:00
Ahmed Adan 88c665d872 feat: add flatpak support to brewfile 2025-11-25 11:39:26 -05:00
Mike McQuaid c7c9c12620 Homebrew 4.7.0 deprecations/disables/removals
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2025-11-05 14:46:12 +00:00
Mike McQuaid cf8835eff7 test/bundle: add additional test coverage.
Add missing test coverage, requires, fix a TODO and remove `needs_macos`
from a cask test.
2025-04-01 15:17:19 +01:00
Carlo CabreraandCarlo Cabrera f7ee1902e4 bundle: require more lazily
This will hopefully make using `brew bundle` a little bit snappier.
2025-03-24 22:48:58 +08:00
Mike McQuaidandBo Anderson bdeca530ff Migrate Homebrew/bundle to Homebrew/brew
Co-authored-by: Bo Anderson <mail@boanderson.me>
2025-03-19 06:47:01 +00:00