5014 Commits

Author SHA1 Message Date
Douglas Eichelberger
29f93fb6f2 Add tests 2023-04-04 18:14:54 -07:00
Issy Long
7cfa544aec
cask/utils: Make more noise when encountering undefined methods
- https://github.com/Homebrew/homebrew-cask/actions/runs/4608585102/jobs/8144571098
  introduced syntax errors for the `mattermost` cask (`autoupdates`
  instead of `auto_updates`), but CI didn't fail so we didn't notice
  until it shipped to users and broke `brew update`.
2023-04-04 17:08:54 +01:00
Carlo Cabrera
5194e5c65e
Check for --eval-all before using HOMEBREW_EVAL_ALL 2023-04-05 00:03:58 +08:00
Mike McQuaid
41e7ee7b51
Merge pull request #15125 from issyl0/rubocops-cask-verified-url-with-path-ending-slash
rubocops/cask: Ensure that "verified" URLs with paths end with "/"
2023-04-04 16:30:09 +01:00
Issy Long
7bb20a3b83
Skip if the URL stanza has only two path components
https://github.com/Homebrew/homebrew-cask-fonts/pull/7336#discussion_r1156325651
2023-04-04 16:11:44 +01:00
Carlo Cabrera
506f6c81a7
Support --dependents flag on macOS 2023-04-04 16:20:37 +08:00
Carlo Cabrera
c125079d0f
determine-test-runners: allow usage on macOS without --dependents 2023-04-04 13:54:35 +08:00
Carlo Cabrera
3d03d243a4
determine-test-runners: test failure modes (again) 2023-04-04 13:25:44 +08:00
Carlo Cabrera
e191dbfb9e
Improve style 2023-04-04 13:20:03 +08:00
Carlo Cabrera
7ff2382d74
determine-test-runners: fix parallel tests
Since these tests run in parallel, we want to minimise our reliance on
environment variables. Also, we need to make sure that different
examples write to different paths.
2023-04-04 12:16:54 +08:00
Carlo Cabrera
4cb50a38c7
Improve versioned macOS test 2023-04-04 02:42:14 +08:00
Carlo Cabrera
839b7d44cc
determine-test-runners: test failure modes 2023-04-04 02:30:13 +08:00
Carlo Cabrera
3d7d4c60f7
determine-test-runners_spec: hardcode fewer things 2023-04-04 02:13:35 +08:00
Carlo Cabrera
3dc66fae9f
determine-test-runners: add non-trivial tests 2023-04-04 01:46:33 +08:00
Carlo Cabrera
140e751ec6
Fix brew style 2023-04-04 01:12:05 +08:00
Carlo Cabrera
d5dc9ee5e0
determine-test-runners: test --dependents 2023-04-04 01:02:47 +08:00
Carlo Cabrera
4dc370ca24
Add some more tests 2023-04-04 00:45:54 +08:00
Carlo Cabrera
ae63b23472
determine-test-runners: add a test
I'll add more substantial tests shortly, but let's start with this one.
2023-04-03 22:42:00 +08:00
Mike McQuaid
a88397096d
Merge pull request #15121 from singingwolfboy/pip-no-build-isolation
Python: allow --no-build-isolation for pip install
2023-04-03 13:14:19 +01:00
Issy Long
28f8cbe8da
Handle when the URL has interpolation: use source not str_content
- We see this a lot in real Casks.
2023-04-02 23:39:43 +01:00
Issy Long
41c35986f8
Simplify the 'should not start with https?://' message wording
Co-authored-by: Markus Reiter <me@reitermark.us>
2023-04-02 22:43:57 +01:00
Issy Long
21da074346
Only 'verified' stanzas with 0 or >1 path components should end with "/"
Handle good things like:

```ruby
url "https://example.org/download",
    verified: "example.org/download" # This is fine.
```

And bad things like:

```ruby
url "https://example.org/",
    verified: "example.org" # This should end with a slash.
```
2023-04-02 22:26:23 +01:00
Issy Long
17c0eaab25
Fix indentation of verified in url stanza examples 2023-04-02 16:41:29 +01:00
Issy Long
b586d97f84
rubocops/cask: Ensure that "verified" URLs with paths end with "/"
- These were being fixed manually[1], so let's make a RuboCop for any
  further occurrences since this is a good rule to enforce[2].

[1] - https://github.com/Homebrew/homebrew-cask/pull/144179#issuecomment-1489857249
[2] - https://github.com/Homebrew/homebrew-cask/pull/80965#issuecomment-616232313
2023-04-02 15:29:53 +01:00
David Baumgold
64ff386744 fix tests 2023-04-01 14:32:27 +02:00
David Baumgold
38a2703aa7 Python: allow --no-build-isolation for pip install 2023-04-01 11:31:29 +02:00
apainintheneck
39092fa629 service: handle string run cmd
This was not handled at all during deserialization.
The string argument gets turned into an array internally
but we skip that to preserve all args in the @run_params
variable. That means that we have to handle strings when
deserializing too.
2023-03-31 20:33:21 -07:00
Issy Long
df8e97fef6
Consolidate add_{warning,error} methods into one
- Specify `strictish: true` in `add_error` to specify that it's not a
  super big critical error.
- These will be shown only if `brew audit --strict` is requested.
2023-04-01 01:56:47 +01:00
Issy Long
2b8127d518
Turn cask warnings into errors when --strict is passed (or implied)
- Ignore them and don't show them otherwise.
- Part three of issue 15074:
  > As a result, I propose that all current cask audit warnings are never
  > displayed as warnings but the underlying audit checks turned into
  > errors displayed only with --strict (or one of the other relevant
  > flags).
2023-04-01 01:56:46 +01:00
Issy Long
a4e8f9e22b
audit: Make --display-failures-only the default for Casks
- Cask warnings are really noisy and numerous. Let's only show them if
  the user passes `--strict` or something implying `--strict`, like
  `--new-cask`.
- Additionally remove `display_passes` since we would like silence if
  nothing is wrong with the cask, the same as with formula audits.
2023-04-01 01:56:45 +01:00
Markus Reiter
bdd6523ce8
Deprecate appcast. 2023-03-30 03:29:06 +02:00
Issy Long
039a434936
Merge pull request #14976 from issyl0/rubocop-cask-on-arch-block-order
rubocops/cask: Enforce the order of `on_#{arch}` blocks
2023-03-29 12:10:37 +01:00
Issy Long
222ef50063
Merge pull request #15060 from issyl0/formula-block-component-order 2023-03-28 22:09:15 +01:00
Mike McQuaid
91251d5739
Merge pull request #15059 from dduugg/type-cleanup
Enable typing in Homebrew::Cleanup
2023-03-27 17:45:01 +01:00
Douglas Eichelberger
a7b80532bf Code review changes 2023-03-27 09:28:27 -07:00
Markus Reiter
3da305fa80
Add keyboard_layout stanza. 2023-03-26 08:14:24 +02:00
Issy Long
2d781d23e0
rubocops: Detect unordered stanzas in non-on_* blocks in formulae
- Previously this components order cop only checked for correct stanza
  order inside `on_*` blocks. This commit extends this cop to also check
  for correct stanza order inside `head` and `resource` blocks. This is
  a positive change since it standardizes the order of stanzas in all of
  the places, making formulae more readable.
- Fixes issue 14017.
2023-03-26 02:31:42 +01:00
Douglas Eichelberger
eaeceda31e Enable typing in Homebrew::Cleanup 2023-03-25 13:16:11 -07:00
Issy Long
0af5825dfb
rubocops/cask: on_#{os_version} is after [version & sha256] group
- This still doesn't pass `brew readall` for Casks, but it gets us a
  little closer since if `url` has a `version` interpolated in it, the
  `version` stanza has to come first.
- See https://github.com/Homebrew/homebrew-cask/pull/143201 for the
  current failures.
2023-03-25 16:02:30 +00:00
Issy Long
48b1279b00
cask/audits: on_#{os_version} stanza order is oldest => newest
- This, ie Mojave first, is more common in real Casks than the
  alternative of newest to oldest ie Ventura first.
- Doing it this way reduces the number of offenses from ~500 to ~200.
2023-03-25 14:52:30 +00:00
Issy Long
d97ed0a7c2
rubocops/cask: Ensure ordering of all the on_#{arch,system} blocks
- Complaining about only `on_arm` and `on_intel` was too restrictive
  since casks can have many `on_system` blocks (`on_#{arch}` and
  `on_#{os}`).
- We're a bit of the way there, anyway. Still doesn't support stanza
  ordering within blocks, but that's for another time (there's a
  separate issue that's been open for a while - 14017).
2023-03-25 14:52:29 +00:00
Issy Long
b6062acdbe
rubocops/cask: Enforce the order of on_#{arch} blocks
- These were previously being manually fixed which is time maintainers
  could have spent fixing more important problems.
- I don't work with Casks much at all, so I was unsure as to what the
  existing "arch" and "on_arch_conditional" parts were, if they're
  deprecated or if things were eventually going to migrate to
  `on_#{arch}` blocks?
2023-03-25 14:52:24 +00:00
Issy Long
d43ba7c306
Merge pull request #15013 from issyl0/rubocops-cask-no-overrides 2023-03-25 13:44:19 +00:00
Issy Long
e4156909d4
Only take overrideable stanzas into account
- This skips over stanza names that are not overrideable in `on_*`
  blocks, with the positive side effect that `on_*` blocks themselves
  aren't in the list so we can get rid of another conditional.
- Stanzas overrideable in blocks are defined in `Cask::DSL` by each of
  the methods calling `set_unique_stanza`.
2023-03-23 18:59:29 +00:00
Issy Long
d4d413db62
String interpolations in regexps should also be allowed
- This came up in Cask `simply-fortran`:

```
Scanning /opt/homebrew/Library/Taps/homebrew/homebrew-cask/Casks/simply-fortran.rb
send_node: s(:send, nil, :arch), send_node.parent: s(:begin,
  s(:send, nil, :arch)), send_node.parent.parent: (regexp
  (str "href=.*?simplyfortran[._-]v?(\\d+(?:\\.\\d+)+)")
  (begin
    (send nil :arch))
  (str "\\.dmg")
  (regopt :i))
Casks/simply-fortran.rb:2:3: C: Cask/NoOverrides: Do not use a top-level arch stanza as the default. Add it to an on_{system} block instead.
Use :or_older or :or_newer to specify a range of macOS versions.

  arch arm: "-arm64", intel: "-x86_64"
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected
```
2023-03-23 13:55:00 +00:00
apainintheneck
6ccf21c2c9 Merge branch 'master' into add-service-block-to-formula-api 2023-03-22 20:06:32 -07:00
apainintheneck
801ee5e474 Address feedback
- style nits
- better comments for tests that are not idempotent
- moved appdir placeholder constant to global.rb
2023-03-22 19:43:49 -07:00
Issy Long
0889593e2a
Another failing test for a real Cask, version.csv.first interpolated 2023-03-23 00:02:17 +00:00
Issy Long
e66226aefc
Fix skipping of livecheck block contents in on_* blocks
- This passes the previously failing test for `on_*` blocks with
  `livecheck` blocks with multiple stanzas inside them (eg `url` and
  `strategy`) that weren't being correctly skipped because we weren't
  detecting high enough up the ancestry.
2023-03-22 23:17:32 +00:00
Issy Long
991e5f2f9c
Failing test for mishandling contents of livecheck blocks in on_*
- The Cask `little-snitch4` in `Homebrew/homebrew-cask-versions` was
  failing and it took me a while to figure out _how_. Add a test for
  easier further debugging (and to prevent breakage once the bug is
  fixed).

```
❯ brew tests --only=rubocops/cask/no_overrides
Randomized with seed 29917
1 process for 1 spec, ~ 1 spec per process
F

Failures:

  1) RuboCop::Cop::Cask::NoOverrides when there are livecheck blocks within `on_*` blocks, ignore their contents does not report any offenses
     Failure/Error: DEFAULT_FAILURE_NOTIFIER = lambda { |failure, _opts| raise failure }
       expected `[#<RuboCop::Cop::Offense:0x000000012de636c8 @severity=#<RuboCop::Cop::Severity:0x000000012de636a0 @name=:convention>, @location=#<Parser::Source::Range (string) 244...273>, @message="Do not use a top-level `url` stanza as the default. Add it to an `on_{system}` block instead.\nUse `:or_older` or `:or_newer` to specify a range of macOS versions.\n", @cop_name="Cask/NoOverrides", @status=:unsupported, @corrector=nil>].empty?` to be truthy, got false
     Shared Example Group: "does not report any offenses" called from ./test/rubocops/cask/no_overrides_spec.rb:77
     # ./test/rubocops/cask/shared_examples/cask_cop.rb:24:in `expect_no_offenses'
     # ./test/rubocops/cask/shared_examples/cask_cop.rb:7:in `block (2 levels) in <module:CaskCop>'

Took 2 seconds
Tests Failed
```
2023-03-22 21:41:28 +00:00