498 Commits

Author SHA1 Message Date
Mike McQuaid
e9b4979f40
Add support for Homebrew wrappers
Allow the ability for a system administrator to use
`HOMEBREW_BREW_WRAPPER` and `HOMEBREW_FORCE_BREW_WRAPPER` variables to
enforce the usage of a particular `brew` command for non-trivial (e.g.
`brew --prefix` is considered trivial, it doesn't need to write to the
prefix) Homebrew commands.

This also introduces a `HOMEBREW_ORIGINAL_BREW_FILE` variable for some
internal usage; `HOMEBREW_BREW_FILE` was being used internally for
both "how should we shell out to Homebrew" and "what should we use
to check permissions on Homebrew". `HOMEBREW_ORIGINAL_BREW_FILE` is
now used just for the latter case.

Inspired by conversation in
https://github.com/Homebrew/homebrew-bundle/pull/1551 which suggested
this was worth fixing in wider than just `brew bundle`.
2025-01-07 17:40:18 +00:00
Rui Chen
79ed2c6e61
chore: fix typos
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-12-28 15:53:35 -05:00
Mike McQuaid
4d4531c19d
Revamp installed_on_request handling
- `reinstall` and `upgrade` no longer mark as installed on request,
  with or without names specified, but preserve the version from the
  tab instead
- default `install_on_request` to `false` rather than `true`
- only set installed in request in a tab if it's missing rather than
  false

Co-authored-by: Michael Cho <michael@michaelcho.dev>
2024-11-19 08:39:55 +00:00
Caleb Xu
215fc85579
deprecate_disable: support optional replacement parameter 2024-11-08 15:49:00 -05:00
Douglas Eichelberger
ba3f426726 clean up fixture 2024-11-07 13:00:38 -08:00
Przemysław Kryger
ff03947ba0 Use @@HOMEBREW_PREFIX@@ for replacements in external patches 2024-10-23 16:51:01 +01:00
Przemysław Kryger
a03d65b5c9 Allow HOMEBREW_PREFIX replacement in external patches
This fixes #15925
2024-10-23 15:15:17 +01:00
Douglas Eichelberger
ced4a3a91f Migrate Parlour extensions to Tapioca compilers 2024-10-14 19:50:09 -07:00
Bevan Kay
8b33aa048a
test/fixtures: add app binary with valid info.plist file 2024-10-10 10:41:09 +11:00
Bevan Kay
8852f024a6
test/fixtures: add livecheck-extract-plist cask 2024-10-10 10:41:09 +11:00
Bo Anderson
326a71712f
Revert "Shorten brew tests temporary paths."
This reverts commit 27fb07c0fc622d3e010a8a9f6e0056fd09dc5b1f.
2024-09-27 01:55:26 +01:00
Mike McQuaid
5b46ec70e9
cask/url: deprecate url do blocks.
We're removing these in
https://github.com/Homebrew/homebrew-cask/pull/186501
so let's deprecate them too.
2024-09-26 14:05:25 +01:00
Carlo Cabrera
e03a9fd0be
tests: add an extra byte of randomness
Two bytes should hopefully be plenty.
2024-09-25 22:32:51 +08:00
Mike McQuaid
27fb07c0fc
Shorten brew tests temporary paths.
If you have `HOMEBREW_TEMP` set to a longer path (e.g. the user's
private temporary directory rather than `/private/tmp`), Sequoia will
error out on some tests when forking because the path is too long
(> 104 bytes).

To improve this situation let's:
- use a shorter path for `HOMEBREW_TEMP` by appending `/brew-tests` to
  the existing `HOMEBREW_TEMP` used outside of tests rather than
  creating nested temporary directories
- use the minimal amount of randomness to avoid collisions while
  allowing parallel tests
- use `squeeze` to remove any double slashes in the temporary path
2024-09-24 10:28:18 +01:00
Mike McQuaid
f719090446
Add a bunch more UNDEFINED_CONSTANTS for startup.
This should avoid these getting included globally in future.

I found this list from a combination of
https://github.com/Homebrew/brew/pull/17707/files, looking at the
Gemfile and just looking around myself.
2024-08-16 12:33:26 +01:00
apainintheneck
f6a6979711 Verify more constants are not loaded at startup
Loading different constants can be tricky with all the requires in
Homebrew so we want to strengthen the existing checks to make
sure that things are not getting required when there is a performance
penalty. This expands the existing check to include more constants
beyond `Formula` that we don't expect to be defined and that pull
in a lot of other dependencies.
2024-08-14 19:08:31 -07:00
Mike McQuaid
02d414d79b
Merge pull request #18008 from Homebrew/deprecate-old-style-cmds 2024-08-14 07:45:13 +01:00
apainintheneck
1fe16a5e35 Address feedback
- Move HOMEBREW_TAP_DIRECTORY to startup/config.rb because this file
holds more of the directory constants
- Rename `Commands.cmd_directories` to `Commands.tap_cmd_directories`
to better express that the commands come from taps

This file has the directory constants while the other one has regexes.
Just better organization.
2024-08-10 17:52:26 -07:00
apainintheneck
a3e917afe1 Refactor method to remove extra tap requires
We were selectively requiring the tap.rb file in a few places for
performance reasons. The main method we were referencing was the
`Tap.cmd_directories` method which uses `Pathname` and the `TAP_DIRECTORY`
constant internally. `Tap.cmd_directories` is mostly used in the `Commands`
module and that is loaded very early on in the program so it made sense
to move that command to that module. To facilitate that I moved the
`TAP_DIRECTORY` constant to the top-level and renamed it to
`HOMEBREW_TAP_DIRECTORY`. It now lies in the tap_constants.rb file.

A nice bonus of this refactor is that it speeds up loading external
commands since the tap.rb file is no longer required by default in
those cases.
2024-08-10 13:49:10 -07:00
Douglas Eichelberger
cefae82307 Fix tests 2024-08-10 11:20:53 -07:00
Mike McQuaid
f39b5c1426
Merge pull request #17554 from Homebrew/cask-install-receipt 2024-07-13 10:55:06 -04:00
Bo Anderson
ae9d5f9f14
cli/named_args: raise priority of core casks 2024-07-12 05:27:57 +01:00
Rylan Polster
d17da89382
Include recursive dependencies in cask tabs 2024-07-09 15:25:57 -04:00
Rylan Polster
46cb7f2847
Update tests 2024-07-04 01:47:14 -04:00
Ruoyu Zhong
9cd5078efb
cmd/tab: new command
Add `brew tab`, a new command to edit tab information, as previously
discussed in https://github.com/Homebrew/brew/pull/17125#issuecomment-2068473483.
Currently, this supports marking or unmarking formulae as installed on
request.

Sample usage:

    $ brew tab --installed-on-request curl
    ==> curl is now marked as installed on request.
    $ brew autoremove --dry-run
    [no output]
    $ brew tab --no-installed-on-request curl
    ==> curl is now marked as not installed on request.
    $ brew autoremove --dry-run
    ==> Would autoremove 2 unneeded formulae:
    curl
    rtmpdump

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2024-06-13 11:44:14 +08:00
Bo Anderson
7da94a8f01
Preliminary macOS 15 (Sequoia) support 2024-06-11 02:59:31 +01:00
Aaron Ruan
10987270fa
remove unnecessary cask osdn-incorrect-url-format 2024-05-27 12:33:23 +08:00
Aaron Ruan
0778379501
change tests for auditing OSDN download urls 2024-05-27 00:34:08 +08:00
Mike McQuaid
222fe8ef0b
Homebrew 4.3.0 deprecation/disable/removals.
The usual pass of deprecating/disabling/removing code for the next
minor Homebrew release.
2024-05-07 12:18:04 +01:00
apainintheneck
56ecd42ebd dev-cmd/tests: skip tests that require core if it's not tapped
There were a few tests which require core to be tapped and fail
if it isn't. This is annoying if someone is trying to contribute
to the project and they're using the JSON API instead of having
the core repo tapped locally.

I'm just skipping these because it's the simplest thing to do.
The tests that failed are mostly rubocop tests so it's fine
if they only run on CI.
2024-05-03 00:32:50 -07:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
apainintheneck
6ad02b8e34 formula: internal json v3 dependencies: address feedback
- rename #dependencies_list to #internal_dependencies_hash
  - the initial implementation returned an array but now it doesn't
- simplify usage of #tap in #internal_dependencies_hash
- remove safe navigation operator usages in #internal_dependencies_hash
- better document why implicit dependencies are not included in the API JSON
- add new test fixture formula to better test generation of uses from
  macos bounds with the new internal json format
2024-04-30 23:44:25 -07:00
apainintheneck
541305ae98 Update internal json v3 formula tests 2024-04-27 18:07:54 -07:00
Caleb Xu
a3cfff72fd
formula_installer: conditionally deny network access in sandbox 2024-04-22 22:39:45 -04:00
Douglas Eichelberger
c1a4a806e1 rm unused OutputAsTTY helper 2024-03-30 18:44:39 -07:00
Bo Anderson
326bc3f889
Fix cask source checksum handling 2024-03-19 21:21:37 +00:00
apainintheneck
9ff0f85335 untap_spec: use builtin spec helpers to simplify tests 2024-03-12 22:07:14 -07:00
apainintheneck
11b67e04c2 untap: add tests for finding formulae/casks in each tap
These are regression tests to make sure that this logic is reproducible.
If this logic is not working, it might mean that someone removes a tap
accidentally that still includes a formula or cask that they currently
have installed.

The tests are extravagant and over-engineered but I'm not sure that
there's an easier way to do this without massive integration tests.
2024-03-10 22:33:44 -07:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Mike McQuaid
03e583e746
cask: read bundle version from Info.plist when sensible.
If you're trying to use `brew info --json=v2` to get an installed
version and figure out if it is outdated: you're going to have a bad
time with `auto_updates` casks because `installed_version` alone is not
enough to get the actually currently installed version of the app.

Instead, in these cases, try to read from `Info.plist` if there is one
and use that version.

While we're here, add a `blank?` method to `Version` so we can use it
for `present?` checks (making a `null?` `Version` object `blank?`).

Co-authored-by: Markus Reiter <me@reitermark.us>
2024-03-06 15:52:16 +00:00
apainintheneck
f1f2e24aec test fixture: pretty print JSON for readability 2024-02-27 20:55:16 -08:00
apainintheneck
200fe2a6b7 api/formula: Add tests for internal JSON v3
These tests cover both generating and loading formulae from the JSON
bundle. The tests are not comprehensive but they do provide a nice
sanity check that things are working as expected.
2024-02-27 20:55:16 -08:00
apainintheneck
5cc1c85a5f cachable: Move registry to test directory
Now we only include the cachable registry when running tests.
We basically just load it first and add a bunch of methods to
it before loading the rest of the formula files when we require
global.rb. I added a check to make sure this require order is
preserved.

I also made a bunch of methods private, stop excluding classes
that inherit from casks since it's unnecessary and add more docs.
2024-02-26 20:41:10 -08:00
Douglas Eichelberger
ab62a717b9
Merge pull request #16407 from dduugg/default-prefixes
Remove redirection for default prefixes
2024-02-19 09:48:26 -08:00
Douglas Eichelberger
c2e48ec79c Extract find_files to helper 2024-02-19 08:28:12 -08:00
Douglas Eichelberger
ab8f5702ac
git grep -l '^shared_examples' | xargs gsed -i 's|^shared_examples|RSpec.shared_examples|g' 2024-02-19 13:57:28 +00:00
Markus Reiter
ad1d50e64a
Clear tap cache after setting up test formula. 2024-02-16 10:44:01 +01:00
Markus Reiter
27189f4aba
Fix stubbing casks in tests. 2024-02-13 18:44:00 +01:00
Douglas Eichelberger
12d32cc69e Manual fixes 2024-02-11 20:13:24 -08:00
Markus Reiter
d1fa91cd78
Clear tap caches after linking cask fixtures. 2024-02-09 23:37:11 +01:00