Merge pull request #6482 from alecclarke/run-style-checks-on-test-casks

Include test casks in the cask style check.
This commit is contained in:
Markus Reiter 2019-10-04 23:15:59 +02:00 committed by GitHub
commit e351e6b31c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 74 additions and 67 deletions

View File

@ -3,6 +3,8 @@ inherit_from: ./.rubocop_shared.yml
Cask/HomepageMatchesUrl:
Description: 'Ensure that the homepage and url match, otherwise add a comment. More info at https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/url.md#when-url-and-homepage-hostnames-differ-add-a-comment'
Enabled: true
Exclude:
- '**/test/support/fixtures/cask/Casks/**/*.rb'
Cask/HomepageUrlTrailingSlash:
Description: 'Ensure that the homepage url has a slash after the domain name.'

View File

@ -31,7 +31,7 @@ module Cask
def cask_paths
@cask_paths ||= if args.empty?
Tap.map(&:cask_dir).select(&:directory?)
Tap.map(&:cask_dir).select(&:directory?).concat(test_cask_paths)
elsif args.any? { |file| File.exist?(file) }
args.map { |path| Pathname(path).expand_path }
else
@ -51,6 +51,13 @@ module Cask
]
end
def test_cask_paths
[
Pathname.new("#{HOMEBREW_LIBRARY}/Homebrew/test/support/fixtures/cask/Casks"),
Pathname.new("#{HOMEBREW_LIBRARY}/Homebrew/test/support/fixtures/third-party/Casks"),
]
end
def normal_args
default_args + ["--parallel"]
end

View File

@ -10,13 +10,13 @@ describe Cask::Cmd::Home, :cask do
it_behaves_like "a command that handles invalid options"
it "opens the homepage for the specified Cask" do
expect(described_class).to receive(:open_url).with("https://brew.sh")
expect(described_class).to receive(:open_url).with("https://brew.sh/")
described_class.run("local-caffeine")
end
it "works for multiple Casks" do
expect(described_class).to receive(:open_url).with("https://brew.sh")
expect(described_class).to receive(:open_url).with("https://brew.sh")
expect(described_class).to receive(:open_url).with("https://brew.sh/")
expect(described_class).to receive(:open_url).with("https://brew.sh/")
described_class.run("local-caffeine", "local-transmission")
end

View File

@ -12,7 +12,7 @@ describe Cask::Cmd::Info, :cask do
described_class.run("local-caffeine")
}.to output(<<~EOS).to_stdout
local-caffeine: 1.2.3
https://brew.sh
https://brew.sh/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/local-caffeine.rb
==> Name
@ -41,7 +41,7 @@ describe Cask::Cmd::Info, :cask do
let(:expected_output) {
<<~EOS
local-caffeine: 1.2.3
https://brew.sh
https://brew.sh/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/local-caffeine.rb
==> Name
@ -50,7 +50,7 @@ describe Cask::Cmd::Info, :cask do
Caffeine.app (App)
local-transmission: 2.61
https://brew.sh
https://brew.sh/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/local-transmission.rb
==> Name
@ -72,7 +72,7 @@ describe Cask::Cmd::Info, :cask do
described_class.run("with-caveats")
}.to output(<<~EOS).to_stdout
with-caveats: 1.2.3
https://brew.sh
https://brew.sh/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/with-caveats.rb
==> Name
@ -97,7 +97,7 @@ describe Cask::Cmd::Info, :cask do
described_class.run("with-conditional-caveats")
}.to output(<<~EOS).to_stdout
with-conditional-caveats: 1.2.3
https://brew.sh
https://brew.sh/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/with-conditional-caveats.rb
==> Name
@ -112,7 +112,7 @@ describe Cask::Cmd::Info, :cask do
described_class.run("with-languages")
}.to output(<<~EOS).to_stdout
with-languages: 1.2.3
https://brew.sh
https://brew.sh/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/with-languages.rb
==> Name
@ -129,7 +129,7 @@ describe Cask::Cmd::Info, :cask do
described_class.run("without-languages")
}.to output(<<~EOS).to_stdout
without-languages: 1.2.3
https://brew.sh
https://brew.sh/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/without-languages.rb
==> Name

View File

@ -5,7 +5,7 @@ describe Cask::Cmd::InternalStanza, :cask do
command = described_class.new("homepage", "local-caffeine")
expect {
command.run
}.to output("https://brew.sh\n").to_stdout
}.to output("https://brew.sh/\n").to_stdout
end
it "raises an exception when stanza is unknown/unsupported" do

View File

@ -80,8 +80,12 @@ describe Cask::Cmd::Style, :cask do
end
it {
expect(subject).to contain_exactly(a_path_ending_with("/homebrew/homebrew-cask/Casks"),
a_path_ending_with("/third-party/homebrew-tap/Casks"))
expect(subject).to contain_exactly(
a_path_ending_with("/homebrew/homebrew-cask/Casks"),
a_path_ending_with("/third-party/homebrew-tap/Casks"),
a_path_ending_with("/Homebrew/test/support/fixtures/cask/Casks"),
a_path_ending_with("/Homebrew/test/support/fixtures/third-party/Casks"),
)
}
end

View File

@ -3,7 +3,7 @@ cask 'bad-checksum' do
sha256 'badbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadbadb'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end

View File

@ -3,6 +3,6 @@ cask 'booby-trap' do
url do
# to be lazily evaluated
fail 'Boom'
raise 'Boom'
end
end

View File

@ -3,7 +3,7 @@ cask 'installer-with-uninstall' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
installer manual: 'Caffeine.app'

View File

@ -1,9 +1,9 @@
cask => 'invalid-header-format' do
cask 'invalid-header-format', :invalid do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end

View File

@ -3,7 +3,7 @@ cask 'invalid-header-token-mismatch-this-text-does-not-belong' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end

View File

@ -3,7 +3,7 @@ cask 'invalid-header-version' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end

View File

@ -3,7 +3,7 @@ cask 'invalid-two-homepage' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
homepage 'https://www.brew.sh/local-caffeine'
app 'Caffeine.app'

View File

@ -4,7 +4,7 @@ cask 'invalid-two-url' do
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
url 'https://brew.sh/caffeine.zip'
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end

View File

@ -4,7 +4,7 @@ cask 'invalid-two-version' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end

View File

@ -3,7 +3,7 @@ cask 'local-caffeine' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end

View File

@ -1,10 +1,10 @@
cask 'local-transmission' do
name 'Transmission'
version '2.61'
sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68'
url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg"
homepage 'https://brew.sh'
name 'Transmission'
homepage 'https://brew.sh/'
app 'Transmission.app'
end

View File

@ -2,7 +2,7 @@ cask 'missing-checksum' do
version '1.2.3'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end

View File

@ -1,5 +1,5 @@
cask 'missing-url' do
version '1.2.3'
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
end

View File

@ -1,4 +1,4 @@
cask 'missing-version' do
url 'https://localhost/something.dmg'
homepage 'https://brew.sh'
url 'https://brew.sh/TestCask.dmg'
homepage 'https://brew.sh/'
end

View File

@ -3,7 +3,7 @@ cask 'no-checksum' do
sha256 :no_check
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end

View File

@ -3,7 +3,7 @@ cask 'bad-checksum' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end

View File

@ -3,7 +3,7 @@ cask 'local-caffeine' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end

View File

@ -3,7 +3,7 @@ cask 'local-transmission' do
sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68'
url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Transmission.app'
end

View File

@ -3,7 +3,7 @@ cask 'version-latest' do
sha256 :no_check
url "file://#{TEST_FIXTURE_DIR}/cask/caffeines.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine Mini.app'
app 'Caffeine Pro.app'

View File

@ -3,7 +3,7 @@ cask 'version-latest' do
sha256 :no_check
url "file://#{TEST_FIXTURE_DIR}/cask/caffeines.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine Mini.app'
app 'Caffeine Pro.app'

View File

@ -3,7 +3,7 @@ cask 'will-fail-if-upgraded' do
sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68'
url "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'container'
end

View File

@ -3,7 +3,7 @@ cask 'with-alt-target' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app', target: 'AnotherName.app'
end

View File

@ -3,7 +3,7 @@ cask 'with-caveats' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'

View File

@ -3,12 +3,12 @@ cask 'with-conditional-caveats' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
# a do block may print and use a DSL
caveats do
puts 'This caveat is conditional' if false # rubocop:disable Lint/LiteralInCondition
puts 'This caveat is conditional' if false # rubocop:disable Lint/LiteralAsCondition
end
end

View File

@ -7,7 +7,7 @@ cask 'with-installable' do
pkg 'MyFancyPkg/Fancy.pkg'
uninstall script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] },
uninstall script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: ['--please'] },
quit: 'my.fancy.package.app',
login_item: 'Fancy',
delete: [

View File

@ -3,7 +3,7 @@ cask 'with-installer-manual' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
installer manual: 'Caffeine.app'
end

View File

@ -1,18 +1,18 @@
cask 'with-languages' do
version '1.2.3'
language "zh" do
sha256 "abc123"
"zh-CN"
language 'zh' do
sha256 'abc123'
'zh-CN'
end
language "en-US", default: true do
sha256 "xyz789"
"en-US"
language 'en-US', default: true do
sha256 'xyz789'
'en-US'
end
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end

View File

@ -5,5 +5,5 @@ cask 'with-non-executable-binary' do
url "file://#{TEST_FIXTURE_DIR}/cask/naked_non_executable"
homepage 'https://brew.sh/with-binary'
binary "naked_non_executable"
binary 'naked_non_executable'
end

View File

@ -9,7 +9,6 @@ cask 'with-postflight-multi' do
postflight do
end
postflight do
end
end

View File

@ -9,7 +9,6 @@ cask 'with-preflight-multi' do
preflight do
end
preflight do
end
end

View File

@ -3,7 +3,7 @@ cask 'with-two-apps-correct' do
sha256 '3178fbfd1ea5d87a2a0662a4eb599ebc9a03888e73f37538d9f3f6ee69d2368e'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeines.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine Mini.app'
app 'Caffeine Pro.app'

View File

@ -3,7 +3,7 @@ cask 'with-two-apps-subdir' do
sha256 'd687c22a21c02bd8f07da9302c8292b93a04df9a929e3f04d09aea6c76f75c65'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeines-subdir.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeines/Caffeine Mini.app'
app 'Caffeines/Caffeine Pro.app'

View File

@ -7,5 +7,5 @@ cask 'with-uninstall-early-script' do
pkg 'MyFancyPkg/Fancy.pkg'
uninstall early_script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] }
uninstall early_script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: ['--please'] }
end

View File

@ -8,6 +8,5 @@ cask 'with-uninstall-multi' do
pkg 'MyFancyPkg/Fancy.pkg'
uninstall rmdir: "#{TEST_TMPDIR}/empty_directory_path"
uninstall delete: "#{TEST_TMPDIR}/empty_directory_path"
end

View File

@ -9,7 +9,6 @@ cask 'with-uninstall-postflight-multi' do
uninstall_postflight do
end
uninstall_postflight do
end
end

View File

@ -9,7 +9,6 @@ cask 'with-uninstall-preflight-multi' do
uninstall_preflight do
end
uninstall_preflight do
end
end

View File

@ -16,6 +16,6 @@ cask 'with-uninstall-script-app' do
uninstall script: {
executable: "#{appdir}/MyFancyApp.app/uninstall.sh",
sudo: false
sudo: false,
}
end

View File

@ -7,5 +7,5 @@ cask 'with-uninstall-script' do
pkg 'MyFancyPkg/Fancy.pkg'
uninstall script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] }
uninstall script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: ['--please'] }
end

View File

@ -7,5 +7,5 @@ cask 'with-zap-early-script' do
pkg 'MyFancyPkg/Fancy.pkg'
zap early_script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] }
zap early_script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: ['--please'] }
end

View File

@ -8,6 +8,5 @@ cask 'with-zap-multi' do
pkg 'MyFancyPkg/Fancy.pkg'
zap rmdir: "#{TEST_TMPDIR}/empty_directory_path"
zap delete: "#{TEST_TMPDIR}/empty_directory_path"
end

View File

@ -7,5 +7,5 @@ cask 'with-zap-script' do
pkg 'MyFancyPkg/Fancy.pkg'
zap script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: %w[--please] }
zap script: { executable: 'MyFancyPkg/FancyUninstaller.tool', args: ['--please'] }
end

View File

@ -11,7 +11,7 @@ cask 'with-zap' do
zap script: {
executable: 'MyFancyPkg/FancyUninstaller.tool',
args: %w[--please],
args: ['--please'],
},
quit: 'my.fancy.package.app',
login_item: 'Fancy',

View File

@ -3,7 +3,7 @@ cask 'without-languages' do
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
app 'Caffeine.app'
end