Skip to content
Snippets Groups Projects
Unverified Commit e351e6b3 authored by Markus Reiter's avatar Markus Reiter Committed by GitHub
Browse files

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

Include test casks in the cask style check.
parents b7e0eaae 45806f6a
No related branches found
No related tags found
No related merge requests found
Showing
with 44 additions and 31 deletions
......@@ -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.'
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......@@ -3,6 +3,6 @@ cask 'booby-trap' do
url do
# to be lazily evaluated
fail 'Boom'
raise 'Boom'
end
end
......@@ -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'
......
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
......@@ -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
......@@ -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
......@@ -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'
......
......@@ -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
......@@ -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
......@@ -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
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
......@@ -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
cask 'missing-url' do
version '1.2.3'
homepage 'https://brew.sh'
homepage 'https://brew.sh/'
end
cask 'missing-version' do
url 'https://localhost/something.dmg'
homepage 'https://brew.sh'
url 'https://brew.sh/TestCask.dmg'
homepage 'https://brew.sh/'
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment