Add arm: and intel: arguments to cask sha256 stanza
This commit is contained in:
parent
5047d4249e
commit
686e02b7ce
@ -230,8 +230,13 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @api public
|
# @api public
|
||||||
def sha256(arg = nil)
|
def sha256(arg = nil, arm: nil, intel: nil)
|
||||||
set_unique_stanza(:sha256, arg.nil?) do
|
should_return = arg.blank? && arm.blank? && intel.blank?
|
||||||
|
|
||||||
|
set_unique_stanza(:sha256, should_return) do
|
||||||
|
@on_system_blocks_exist = true if arm.present? || intel.present?
|
||||||
|
|
||||||
|
arg ||= on_arch_conditional(arm: arm, intel: intel)
|
||||||
case arg
|
case arg
|
||||||
when :no_check
|
when :no_check
|
||||||
arg
|
arg
|
||||||
|
|||||||
@ -214,7 +214,7 @@ describe Cask::Cask, :cask do
|
|||||||
|
|
||||||
describe "#to_hash_with_variations" do
|
describe "#to_hash_with_variations" do
|
||||||
let!(:original_macos_version) { MacOS.full_version.to_s }
|
let!(:original_macos_version) { MacOS.full_version.to_s }
|
||||||
let(:expected_variations) {
|
let(:expected_versions_variations) {
|
||||||
<<~JSON
|
<<~JSON
|
||||||
{
|
{
|
||||||
"arm64_big_sur": {
|
"arm64_big_sur": {
|
||||||
@ -243,6 +243,28 @@ describe Cask::Cask, :cask do
|
|||||||
}
|
}
|
||||||
JSON
|
JSON
|
||||||
}
|
}
|
||||||
|
let(:expected_sha256_variations) {
|
||||||
|
<<~JSON
|
||||||
|
{
|
||||||
|
"monterey": {
|
||||||
|
"url": "file://#{TEST_FIXTURE_DIR}/cask/caffeine-intel.zip",
|
||||||
|
"sha256": "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b"
|
||||||
|
},
|
||||||
|
"big_sur": {
|
||||||
|
"url": "file://#{TEST_FIXTURE_DIR}/cask/caffeine-intel.zip",
|
||||||
|
"sha256": "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b"
|
||||||
|
},
|
||||||
|
"catalina": {
|
||||||
|
"url": "file://#{TEST_FIXTURE_DIR}/cask/caffeine-intel.zip",
|
||||||
|
"sha256": "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b"
|
||||||
|
},
|
||||||
|
"mojave": {
|
||||||
|
"url": "file://#{TEST_FIXTURE_DIR}/cask/caffeine-intel.zip",
|
||||||
|
"sha256": "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JSON
|
||||||
|
}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
# Use a more limited symbols list to shorten the variations hash
|
# Use a more limited symbols list to shorten the variations hash
|
||||||
@ -263,12 +285,20 @@ describe Cask::Cask, :cask do
|
|||||||
MacOS.full_version = original_macos_version
|
MacOS.full_version = original_macos_version
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the correct variations hash" do
|
it "returns the correct variations hash for a cask with multiple versions" do
|
||||||
c = Cask::CaskLoader.load("multiple-versions")
|
c = Cask::CaskLoader.load("multiple-versions")
|
||||||
h = c.to_hash_with_variations
|
h = c.to_hash_with_variations
|
||||||
|
|
||||||
expect(h).to be_a(Hash)
|
expect(h).to be_a(Hash)
|
||||||
expect(JSON.pretty_generate(h["variations"])).to eq expected_variations.strip
|
expect(JSON.pretty_generate(h["variations"])).to eq expected_versions_variations.strip
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns the correct variations hash for a cask different sha256s on each arch" do
|
||||||
|
c = Cask::CaskLoader.load("sha256-arch")
|
||||||
|
h = c.to_hash_with_variations
|
||||||
|
|
||||||
|
expect(h).to be_a(Hash)
|
||||||
|
expect(JSON.pretty_generate(h["variations"])).to eq expected_sha256_variations.strip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -126,6 +126,34 @@ describe Cask::DSL, :cask do
|
|||||||
|
|
||||||
expect(cask.sha256).to eq("imasha2")
|
expect(cask.sha256).to eq("imasha2")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with a different arm and intel checksum" do
|
||||||
|
let(:cask) do
|
||||||
|
Cask::Cask.new("checksum-cask") do
|
||||||
|
sha256 arm: "imasha2arm", intel: "imasha2intel"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when running on arm" do
|
||||||
|
before do
|
||||||
|
allow(Hardware::CPU).to receive(:type).and_return(:arm)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "stores only the arm checksum" do
|
||||||
|
expect(cask.sha256).to eq("imasha2arm")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when running on intel" do
|
||||||
|
before do
|
||||||
|
allow(Hardware::CPU).to receive(:type).and_return(:intel)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "stores only the intel checksum" do
|
||||||
|
expect(cask.sha256).to eq("imasha2intel")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "language stanza" do
|
describe "language stanza" do
|
||||||
|
|||||||
@ -0,0 +1,12 @@
|
|||||||
|
cask "sha256-arch" do
|
||||||
|
arch arm: "arm", intel: "intel"
|
||||||
|
|
||||||
|
version "1.2.3"
|
||||||
|
sha256 arm: "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94",
|
||||||
|
intel: "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b"
|
||||||
|
|
||||||
|
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine-#{arch}.zip"
|
||||||
|
homepage "https://brew.sh/"
|
||||||
|
|
||||||
|
app "Caffeine.app"
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user