48 Commits

Author SHA1 Message Date
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Bo Anderson
10cbf191dc
Add env to disable finding packages from paths 2024-07-25 11:37:44 +01:00
Bo Anderson
93dbb9593d
Add env to disable Debrew 2024-07-24 06:16:18 +01:00
Mike McQuaid
c5dbd3ca24
Rearrange requires
This improves the load time of most brew commands. For an example of
one of the simplest commands this speeds up:

Without Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     525.0 ms ±  35.8 ms    [User: 229.9 ms, System: 113.1 ms]
  Range (min … max):   465.3 ms … 576.6 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     383.3 ms ±  25.1 ms    [User: 133.0 ms, System: 72.1 ms]
  Range (min … max):   353.0 ms … 443.6 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.37 ± 0.13 times faster than git checkout master; brew help
```

With Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     386.0 ms ±  30.9 ms    [User: 130.2 ms, System: 93.8 ms]
  Range (min … max):   359.5 ms … 469.3 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     330.2 ms ±  32.4 ms    [User: 93.4 ms, System: 73.0 ms]
  Range (min … max):   302.9 ms … 413.9 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.17 ± 0.15 times faster than git checkout master; brew help
```
2024-07-14 08:49:39 -04:00
Douglas Eichelberger
827e943803 Port Homebrew::DevCmd::Test 2024-03-22 09:33:28 -07:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Bo Anderson
a92a36d027
Lazy load Debrew
Fixes terminfo error on some environments
2023-12-06 00:01:25 +00:00
Douglas Eichelberger
02fd0422aa Enable typing in a few more files 2023-03-09 13:42:06 -08:00
Bo Anderson
987abe7773
Prevent require executing some scripts 2022-09-08 01:44:31 +01:00
Bo Anderson
6d5ef3ba2f
test: don't apply timeout with --debug 2021-03-25 16:50:42 +00:00
Bo Anderson
6cd1e5e384
Avoid passing around a massive $LOAD_PATH.
Portable Ruby crashes if the $LOAD_PATH gets too big.
2021-02-26 18:23:48 +00:00
EricFromCanada
a427de5bee capitalization fixes
"curl" is the binary, while "cURL" is the umbrella project.
2021-01-26 15:36:44 -05:00
Rylan Polster
af6be13e7c test: don't try to use Xcode SDK for build requirement 2020-12-21 09:25:29 -05:00
Markus Reiter
650ec514c1 Fix type errors in test. 2020-11-29 21:23:54 +01:00
Markus Reiter
6750448d95 Fix some auto-correctable type errors. 2020-11-29 21:23:54 +01:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Mike McQuaid
0222a83406
test: fix brew style. 2020-09-23 09:01:55 +01:00
Michka Popoff
9da32e3d93 test: make pgrep call portable
Fixes (on linux), for example for the ninja formula test:

```
pgrep
-P
83252
{out: :close}}
Invalid preceding regular expressionpgrep: write error: Bad file descriptor
Error: ninja: failed
An exception occurred within a child process:
  BuildError: Failed executing: pgrep -P 83252 {out: :close}
```

Using File:NULL is more portable.
2020-09-22 23:35:10 +02:00
Mike McQuaid
541fecea22
test: check for pgrep/pkill for developers/CI.
If people are running `brew test` but don't have `pgrep` or `pkill`
installed the forked processes may never be killed. This is not a big
deal on a user's machine but on CI may make a job block and never
complete/timeout successfully.
2020-09-17 13:05:01 +01:00
William Ma
fa7bd3bff6 args: Migrate usage of args loading methods to args.named 2020-08-23 09:02:20 -04:00
Markus Reiter
490e503b1b Replace Homebrew.args with Context. 2020-08-06 16:13:14 +02:00
Markus Reiter
bace9ecc34 Pass verbose? to Formula#verify_download_integrity. 2020-08-06 16:13:14 +02:00
Markus Reiter
5caafe413e Pass debug? to Formula#brew and Formula#run_test. 2020-08-06 16:12:52 +02:00
Bo Anderson
7f46d4ec3c build, test: set Homebrew.args 2020-08-01 18:27:15 +01:00
Bo Anderson
20c6a3f325 build, test: fix debrew not working 2020-08-01 18:26:56 +01:00
Markus Reiter
276c570c16 Pass individual args explicitly to ENV extensions. 2020-07-28 02:52:45 +02:00
Markus Reiter
25b3632c4c Pass args to ENV instead of using global args. 2020-07-25 03:57:43 +02:00
Markus Reiter
6b0b25cd00 Pass keep_tmp? and interactive? instead of using global args. 2020-07-25 02:37:10 +02:00
Bo Anderson
41a666febb ENV/std: port superenv SDK changes 2020-04-23 18:11:10 +01:00
Mike McQuaid
7da922cd5c
test: ensure pkill is run even without exception.
This should make it easier to cleanup after test failures or successes.

It may also allow simplification of `test do` blocks if they can assume
that all subprocesses will be killed.
2020-04-15 19:47:05 +01:00
Alexander Bayandin
bfcba0f5f0 Library/Homebrew: add free_port test helper
Co-Authored-By: Mike McQuaid <mike@mikemcquaid.com>
2020-03-31 00:00:11 +01:00
Mike McQuaid
a15ce054c8
test: revert renaming test_args method. 2020-01-13 14:56:59 +00:00
Gautham Goli
eadf17881d
Homebrew/test.rb: Reuse test_args method 2020-01-13 14:51:50 +00:00
Mike McQuaid
2bb0ad6560
test: parse arguments. 2020-01-02 13:56:19 +00:00
Gautham Goli
959b88266d
ARGV: Replace usages of ARGV.resolved_formulae with Homebrew.args 2020-01-02 13:56:19 +00:00
Shaun Jackman
4ab7eb93d7 test: Avoid pgrep -q, not available with GNU pgrep 2019-05-05 21:00:27 -07:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
4b369962d3
test: kill all subprocesses on timeout.
Fixes #5885.
2019-04-19 14:42:26 +09:00
William Woodruff
367629d289
utils: Use JSON to marshal child errors
Replaces our serialization of child process
errors via Marshal with JSON, preventing
unintentional or malicious code execution outside
of the build sandbox.

Additionally, adds tests for the new behavior.
2018-09-04 11:03:32 -04:00
Mike McQuaid
7df5b7057e
Revert "Use JSON to marshal errors from children" 2018-08-18 08:20:13 +01:00
William Woodruff
5c90833f0a
Use JSON to marshal errors from children 2018-08-17 15:23:08 -04:00
Markus Reiter
175ca909ee Clean up code style and remove .rubocop_todo.yml. 2017-10-08 16:10:37 +02:00
Markus Reiter
2d6ae61314 Re-revert "Fix operator spacing." 2017-06-02 19:22:05 +02:00
ilovezfs
197392b56d Revert "Fix operator spacing." 2017-06-01 04:06:40 -07:00
Markus Reiter
d34ba7395b Fix operator spacing. 2017-05-31 19:53:41 +02:00
Uladzislau Shablinski
092d4712a1 Update commit when resolving the formula (#536) 2016-07-17 16:56:13 +08:00
BrewTestBot
13d544e11e Core files style updates.
Closes Homebrew/homebrew#42354.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-03 13:22:35 +01:00
Xu Cheng
b621edf89d sandbox test 2015-04-15 19:51:54 +08:00