As I mentioned in #15146, two `Cask::DSL` tests failed on my local
machine, even on `master`. `git bisect` suggested that it was #14998
that introduced those failures. It turned out that the tests here could
fail under certain locale settings, like this one below:
$ defaults read -g AppleLanguages
(
"en-GB",
"zh-Hans-SG"
)
This is not actually a regression. With the aforementioned locale
settings, an explicit `let(:languages) { ["en"] }` setting would result
in locales being considered in the following order: `en`, `en-GB`,
`zh-Hans-SG`. For each of them, the `detect` method from `Locale` is
called, with `locale_groups` as `[["zh"], ["en-US"]]`, the list of
locales defined in the test cask.
def detect(locale_groups)
locale_groups.find { |locales| locales.any? { |locale| eql?(locale) } } ||
locale_groups.find { |locales| locales.any? { |locale| include?(locale) } }
end
Neither of `en` and `en-GB` satisfies the `detect` conditions. (Note
that `Locale.parse("en").include?("en-US")` evaluates to `false`.) But
`zh-Hans-SG` does (because `Locale.parse("zh-Hans-SG").include?("zh")`
is `true`). So, despite having `:languages` set to `en`, the Chinese
locale was still used.
This could be fixed by generalising the test cask's English locale
settings from `en-US` to `en`. This is already the case for most
existing casks:
$ grep 'language "en.*", default: true' Casks/*.rb
Casks/battle-net.rb: language "en", default: true do
Casks/cave-story.rb: language "en", default: true do
Casks/firefox.rb: language "en", default: true do
Casks/libreoffice-language-pack.rb: language "en-GB", default: true do
Casks/libreoffice-language-pack.rb: language "en-GB", default: true do
Casks/openoffice.rb: language "en", default: true do
Casks/seamonkey.rb: language "en-US", default: true do
Casks/thunderbird.rb: language "en", default: true do
Casks/wondershare-edrawmax.rb: language "en", default: true do
Note that this should make the language stanza tests independent of
locale settings, because `zh` and `en` should be able to capture all the
test cases.
Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
- Since comment detection is only used in `Stanza`, move it there.
- The `stanzaify` method was only in `CaskBlock` since the other use of
`Stanza.new` was. Since it's only used in one other place, move it to
where it's used.
- A variant of this was an ancient TODO from 2018 (with `if/else` blocks).
- Now in 2023 we have `on_*` blocks within Casks that are very common.
- The most common stanzas present inside `on_*` blocks are `version`,
`sha256` and `url`. So I feel like it's worth keeping a consistent
style for these inside and outside `on_*` blocks.
This commit includes `--no-mac-metadata` `--no-acls` and `--no-xattrs`
in `default_tar_args` for `brew bottle` command.
Although `default_tar_args` is only active when `--only-json-tab` is
not passed, in which case we don't require reproducible bottles, it is
nonetheless beneficial to "regularize" tarball creation. In
particular, this resolves a sporadic `brew tests
--only=dev-cmd/bottle:20` failure (see
https://github.com/orgs/Homebrew/discussions/4376 and
https://github.com/Homebrew/brew/pull/14997).
Furthermore, with `gnu tar`, `--no-acls` and `--no-xattrs` are default
flags. As for "mac metadata", although I couldn't find official
documentation, this post (https://superuser.com/a/61188) shares some
info:
- Resource forks (resource forks have been extended attributes since 10.4)
- Custom icons set in Finder and the images of Icon\r files
- Metadata in PSD files
- Objects stored in scpt files, AppleScript Editor window state, descriptions of scripts
- Information about aliases (aliases stop working if extended attributes are removed)
- Quarantine status or source URLs of files downloaded from the internet
- Spotlight comments
- Encoding of files saved with TextEdit
- Caret position of files opened with TextMate
- Skim notes
None of these is supposed to be in the bottle I believe.
- Cask source paths were added to the API in 844db75361. The main
`everything.json` file was updated with the new data in that commit,
but this one was missed causing local test failures.
Before:
```
Cask::Cask#to_h when loaded from cask file returns expected hash
Failure/Error: expect(JSON.pretty_generate(hash)).to eq(expected_json_after_ventura)
[...]
Diff:
@@ -93,7 +93,7 @@
"en",
"eo"
],
- "ruby_source_path": "Formula/everything.rb",
+ "ruby_source_path": "Casks/everything.rb",
"ruby_source_checksum": {
"sha256": "b2707d1952f02c3fa566b7ad2a707a847a959d36f51d3dee642dbe5deec12f27"
}
# ./test/cask/cask_spec.rb:231:in `block (4 levels) in <top (required)>'
# ./test/support/helper/spec/shared_context/homebrew_cask.rb:52:in `block (2 levels) in <top (required)>'
```