Merge pull request #10148 from SeekingMeaning/bottle-spec-reformat
bottle_spec: more cleanup
This commit is contained in:
commit
47c584545d
@ -76,9 +76,7 @@ describe Homebrew do
|
|||||||
subject(:homebrew) { described_class }
|
subject(:homebrew) { described_class }
|
||||||
|
|
||||||
let(:hello_hash_big_sur) {
|
let(:hello_hash_big_sur) {
|
||||||
JSON.parse(
|
JSON.parse stub_hash(
|
||||||
stub_hash(
|
|
||||||
{
|
|
||||||
"name": "hello",
|
"name": "hello",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"path": "/home/hello.rb",
|
"path": "/home/hello.rb",
|
||||||
@ -87,14 +85,10 @@ describe Homebrew do
|
|||||||
"filename": "hello-1.0.big_sur.bottle.tar.gz",
|
"filename": "hello-1.0.big_sur.bottle.tar.gz",
|
||||||
"local_filename": "hello--1.0.big_sur.bottle.tar.gz",
|
"local_filename": "hello--1.0.big_sur.bottle.tar.gz",
|
||||||
"sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
"sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
let(:hello_hash_catalina) {
|
let(:hello_hash_catalina) {
|
||||||
JSON.parse(
|
JSON.parse stub_hash(
|
||||||
stub_hash(
|
|
||||||
{
|
|
||||||
"name": "hello",
|
"name": "hello",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"path": "/home/hello.rb",
|
"path": "/home/hello.rb",
|
||||||
@ -103,14 +97,10 @@ describe Homebrew do
|
|||||||
"filename": "hello-1.0.catalina.bottle.tar.gz",
|
"filename": "hello-1.0.catalina.bottle.tar.gz",
|
||||||
"local_filename": "hello--1.0.catalina.bottle.tar.gz",
|
"local_filename": "hello--1.0.catalina.bottle.tar.gz",
|
||||||
"sha256": "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
"sha256": "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
let(:unzip_hash_big_sur) {
|
let(:unzip_hash_big_sur) {
|
||||||
JSON.parse(
|
JSON.parse stub_hash(
|
||||||
stub_hash(
|
|
||||||
{
|
|
||||||
"name": "unzip",
|
"name": "unzip",
|
||||||
"version": "2.0",
|
"version": "2.0",
|
||||||
"path": "/home/unzip.rb",
|
"path": "/home/unzip.rb",
|
||||||
@ -119,14 +109,10 @@ describe Homebrew do
|
|||||||
"filename": "unzip-2.0.big_sur.bottle.tar.gz",
|
"filename": "unzip-2.0.big_sur.bottle.tar.gz",
|
||||||
"local_filename": "unzip--2.0.big_sur.bottle.tar.gz",
|
"local_filename": "unzip--2.0.big_sur.bottle.tar.gz",
|
||||||
"sha256": "16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72",
|
"sha256": "16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72",
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
let(:unzip_hash_catalina) {
|
let(:unzip_hash_catalina) {
|
||||||
JSON.parse(
|
JSON.parse stub_hash(
|
||||||
stub_hash(
|
|
||||||
{
|
|
||||||
"name": "unzip",
|
"name": "unzip",
|
||||||
"version": "2.0",
|
"version": "2.0",
|
||||||
"path": "/home/unzip.rb",
|
"path": "/home/unzip.rb",
|
||||||
@ -135,16 +121,12 @@ describe Homebrew do
|
|||||||
"filename": "unzip-2.0.catalina.bottle.tar.gz",
|
"filename": "unzip-2.0.catalina.bottle.tar.gz",
|
||||||
"local_filename": "unzip--2.0.catalina.bottle.tar.gz",
|
"local_filename": "unzip--2.0.catalina.bottle.tar.gz",
|
||||||
"sha256": "d9cc50eec8ac243148a121049c236cba06af4a0b1156ab397d0a2850aa79c137",
|
"sha256": "d9cc50eec8ac243148a121049c236cba06af4a0b1156ab397d0a2850aa79c137",
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
specify "::parse_json_files" do
|
specify "::parse_json_files" do
|
||||||
Tempfile.open("hello--1.0.big_sur.bottle.json") do |f|
|
Tempfile.open("hello--1.0.big_sur.bottle.json") do |f|
|
||||||
f.write(
|
f.write stub_hash(
|
||||||
stub_hash(
|
|
||||||
{
|
|
||||||
"name": "hello",
|
"name": "hello",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"path": "/home/hello.rb",
|
"path": "/home/hello.rb",
|
||||||
@ -153,8 +135,6 @@ describe Homebrew do
|
|||||||
"filename": "hello-1.0.big_sur.bottle.tar.gz",
|
"filename": "hello-1.0.big_sur.bottle.tar.gz",
|
||||||
"local_filename": "hello--1.0.big_sur.bottle.tar.gz",
|
"local_filename": "hello--1.0.big_sur.bottle.tar.gz",
|
||||||
"sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
"sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
f.close
|
f.close
|
||||||
expect(
|
expect(
|
||||||
@ -206,7 +186,7 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Pathname("testball-1.0.big_sur.bottle.json").write stub_hash(
|
Pathname("#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json").write stub_hash(
|
||||||
"name": "testball",
|
"name": "testball",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"path": "#{core_tap.path}/Formula/testball.rb",
|
"path": "#{core_tap.path}/Formula/testball.rb",
|
||||||
@ -217,7 +197,7 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
"sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
"sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||||
)
|
)
|
||||||
|
|
||||||
Pathname("testball-1.0.catalina.bottle.json").write stub_hash(
|
Pathname("#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json").write stub_hash(
|
||||||
"name": "testball",
|
"name": "testball",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"path": "#{core_tap.path}/Formula/testball.rb",
|
"path": "#{core_tap.path}/Formula/testball.rb",
|
||||||
@ -230,8 +210,8 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
FileUtils.rm_f "testball-1.0.catalina.bottle.json"
|
FileUtils.rm_f "#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||||
FileUtils.rm_f "testball-1.0.big_sur.bottle.json"
|
FileUtils.rm_f "#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds the bottle block to a formula that has none" do
|
it "adds the bottle block to a formula that has none" do
|
||||||
@ -246,10 +226,9 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
brew "bottle",
|
brew "bottle",
|
||||||
"--merge",
|
"--merge",
|
||||||
"--write",
|
"--write",
|
||||||
"testball-1.0.big_sur.bottle.json",
|
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
|
||||||
"testball-1.0.catalina.bottle.json"
|
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||||
}.to output(
|
}.to output(<<~EOS).to_stdout
|
||||||
<<~EOS,
|
|
||||||
==> testball
|
==> testball
|
||||||
bottle do
|
bottle do
|
||||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||||
@ -258,10 +237,8 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina
|
sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
).to_stdout
|
|
||||||
|
|
||||||
expect((core_tap.path/"Formula/testball.rb").read).to eq(
|
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||||
<<~EOS,
|
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
desc "Some test"
|
desc "Some test"
|
||||||
homepage "https://brew.sh/testball"
|
homepage "https://brew.sh/testball"
|
||||||
@ -292,13 +269,12 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
|
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "replaces the bottle block in a formula that already has a bottle block" do
|
it "replaces the bottle block in a formula that already has a bottle block" do
|
||||||
core_tap.path.cd do
|
core_tap.path.cd do
|
||||||
system "git", "init"
|
system "git", "init"
|
||||||
bottle_block = <<~EOS
|
setup_test_formula "testball", bottle_block: <<~EOS
|
||||||
|
|
||||||
bottle do
|
bottle do
|
||||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||||
@ -307,7 +283,6 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
sha256 "16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72" => :catalina
|
sha256 "16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72" => :catalina
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
setup_test_formula("testball", "", bottle_block)
|
|
||||||
system "git", "add", "--all"
|
system "git", "add", "--all"
|
||||||
system "git", "commit", "-m", "testball 0.1"
|
system "git", "commit", "-m", "testball 0.1"
|
||||||
end
|
end
|
||||||
@ -316,10 +291,9 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
brew "bottle",
|
brew "bottle",
|
||||||
"--merge",
|
"--merge",
|
||||||
"--write",
|
"--write",
|
||||||
"testball-1.0.big_sur.bottle.json",
|
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
|
||||||
"testball-1.0.catalina.bottle.json"
|
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||||
}.to output(
|
}.to output(<<~EOS).to_stdout
|
||||||
<<~EOS,
|
|
||||||
==> testball
|
==> testball
|
||||||
bottle do
|
bottle do
|
||||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||||
@ -328,10 +302,8 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina
|
sha256 "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac" => :catalina
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
).to_stdout
|
|
||||||
|
|
||||||
expect((core_tap.path/"Formula/testball.rb").read).to eq(
|
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||||
<<~EOS,
|
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
desc "Some test"
|
desc "Some test"
|
||||||
homepage "https://brew.sh/testball"
|
homepage "https://brew.sh/testball"
|
||||||
@ -362,7 +334,6 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
|
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails to add the bottle block to a formula that has no bottle block when using --keep-old" do
|
it "fails to add the bottle block to a formula that has no bottle block when using --keep-old" do
|
||||||
@ -378,15 +349,15 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
"--merge",
|
"--merge",
|
||||||
"--write",
|
"--write",
|
||||||
"--keep-old",
|
"--keep-old",
|
||||||
"testball-1.0.big_sur.bottle.json",
|
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
|
||||||
"testball-1.0.catalina.bottle.json"
|
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||||
}.to output("Error: --keep-old was passed but there was no existing bottle block!\n").to_stderr
|
}.to output("Error: --keep-old was passed but there was no existing bottle block!\n").to_stderr
|
||||||
end
|
end
|
||||||
|
|
||||||
it "updates the bottle block in a formula that already has a bottle block when using --keep-old" do
|
it "updates the bottle block in a formula that already has a bottle block when using --keep-old" do
|
||||||
core_tap.path.cd do
|
core_tap.path.cd do
|
||||||
system "git", "init"
|
system "git", "init"
|
||||||
bottle_block = <<~EOS
|
setup_test_formula "testball", bottle_block: <<~EOS
|
||||||
|
|
||||||
bottle do
|
bottle do
|
||||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||||
@ -394,7 +365,6 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
sha256 "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059" => :high_sierra
|
sha256 "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059" => :high_sierra
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
setup_test_formula("testball", "", bottle_block)
|
|
||||||
system "git", "add", "--all"
|
system "git", "add", "--all"
|
||||||
system "git", "commit", "-m", "testball 0.1"
|
system "git", "commit", "-m", "testball 0.1"
|
||||||
end
|
end
|
||||||
@ -404,10 +374,9 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
"--merge",
|
"--merge",
|
||||||
"--write",
|
"--write",
|
||||||
"--keep-old",
|
"--keep-old",
|
||||||
"testball-1.0.big_sur.bottle.json",
|
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
|
||||||
"testball-1.0.catalina.bottle.json"
|
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
|
||||||
}.to output(
|
}.to output(<<~EOS).to_stdout
|
||||||
<<~EOS,
|
|
||||||
==> testball
|
==> testball
|
||||||
bottle do
|
bottle do
|
||||||
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
root_url "#{HOMEBREW_BOTTLE_DEFAULT_DOMAIN}"
|
||||||
@ -417,10 +386,8 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
sha256 "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059" => :high_sierra
|
sha256 "6971b6eebf4c00eaaed72a1104a49be63861eabc95d679a0c84040398e320059" => :high_sierra
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
).to_stdout
|
|
||||||
|
|
||||||
expect((core_tap.path/"Formula/testball.rb").read).to eq(
|
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||||
<<~EOS,
|
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
desc "Some test"
|
desc "Some test"
|
||||||
homepage "https://brew.sh/testball"
|
homepage "https://brew.sh/testball"
|
||||||
@ -452,6 +419,5 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
|||||||
|
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -123,7 +123,7 @@ RSpec.shared_context "integration test" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_test_formula(name, content = nil, bottle_block = nil)
|
def setup_test_formula(name, content = nil, bottle_block: nil)
|
||||||
case name
|
case name
|
||||||
when /^testball/
|
when /^testball/
|
||||||
tarball = if OS.linux?
|
tarball = if OS.linux?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user