bottle_spec: reduce code duplication in tests
This commit is contained in:
parent
2424e58b91
commit
13e0188187
@ -196,6 +196,7 @@ describe Homebrew do
|
||||
end
|
||||
|
||||
describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
let(:core_tap) { CoreTap.new }
|
||||
let(:tarball) do
|
||||
if OS.linux?
|
||||
TEST_FIXTURE_DIR/"tarballs/testball-0.1-linux.tbz"
|
||||
@ -204,19 +205,8 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
end
|
||||
end
|
||||
|
||||
it "adds the bottle block to a formula that has none" do
|
||||
core_tap = CoreTap.new
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
setup_test_formula "testball"
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
begin
|
||||
Pathname("testball-1.0.big_sur.bottle.json").write(
|
||||
stub_hash(
|
||||
{
|
||||
before do
|
||||
Pathname("testball-1.0.big_sur.bottle.json").write stub_hash(
|
||||
"name": "testball",
|
||||
"version": "1.0",
|
||||
"path": "#{core_tap.path}/Formula/testball.rb",
|
||||
@ -225,13 +215,9 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
"filename": "hello-1.0.big_sur.bottle.tar.gz",
|
||||
"local_filename": "hello--1.0.big_sur.bottle.tar.gz",
|
||||
"sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
Pathname("testball-1.0.catalina.bottle.json").write(
|
||||
stub_hash(
|
||||
{
|
||||
Pathname("testball-1.0.catalina.bottle.json").write stub_hash(
|
||||
"name": "testball",
|
||||
"version": "1.0",
|
||||
"path": "#{core_tap.path}/Formula/testball.rb",
|
||||
@ -240,9 +226,21 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
"filename": "testball-1.0.catalina.bottle.tar.gz",
|
||||
"local_filename": "testball--1.0.catalina.bottle.tar.gz",
|
||||
"sha256": "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
||||
},
|
||||
),
|
||||
)
|
||||
end
|
||||
|
||||
after do
|
||||
FileUtils.rm_f "testball-1.0.catalina.bottle.json"
|
||||
FileUtils.rm_f "testball-1.0.big_sur.bottle.json"
|
||||
end
|
||||
|
||||
it "adds the bottle block to a formula that has none" do
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
setup_test_formula "testball"
|
||||
system "git", "add", "--all"
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
@ -261,10 +259,6 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
end
|
||||
EOS
|
||||
).to_stdout
|
||||
ensure
|
||||
FileUtils.rm_f "testball-1.0.catalina.bottle.json"
|
||||
FileUtils.rm_f "testball-1.0.big_sur.bottle.json"
|
||||
end
|
||||
|
||||
expect((core_tap.path/"Formula/testball.rb").read).to eq(
|
||||
<<~EOS,
|
||||
@ -302,7 +296,6 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
end
|
||||
|
||||
it "replaces the bottle block in a formula that already has a bottle block" do
|
||||
core_tap = CoreTap.new
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
bottle_block = <<~EOS
|
||||
@ -319,37 +312,6 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
begin
|
||||
Pathname("testball-1.0.big_sur.bottle.json").write(
|
||||
stub_hash(
|
||||
{
|
||||
"name": "testball",
|
||||
"version": "1.0",
|
||||
"path": "#{core_tap.path}/Formula/testball.rb",
|
||||
"cellar": "any_skip_relocation",
|
||||
"os": "big_sur",
|
||||
"filename": "hello-1.0.big_sur.bottle.tar.gz",
|
||||
"local_filename": "hello--1.0.big_sur.bottle.tar.gz",
|
||||
"sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
Pathname("testball-1.0.catalina.bottle.json").write(
|
||||
stub_hash(
|
||||
{
|
||||
"name": "testball",
|
||||
"version": "1.0",
|
||||
"path": "#{core_tap.path}/Formula/testball.rb",
|
||||
"cellar": "any_skip_relocation",
|
||||
"os": "catalina",
|
||||
"filename": "testball-1.0.catalina.bottle.tar.gz",
|
||||
"local_filename": "testball--1.0.catalina.bottle.tar.gz",
|
||||
"sha256": "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
"--merge",
|
||||
@ -367,10 +329,6 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
end
|
||||
EOS
|
||||
).to_stdout
|
||||
ensure
|
||||
FileUtils.rm_f "testball-1.0.catalina.bottle.json"
|
||||
FileUtils.rm_f "testball-1.0.big_sur.bottle.json"
|
||||
end
|
||||
|
||||
expect((core_tap.path/"Formula/testball.rb").read).to eq(
|
||||
<<~EOS,
|
||||
@ -408,7 +366,6 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
end
|
||||
|
||||
it "fails to add the bottle block to a formula that has no bottle block when using --keep-old" do
|
||||
core_tap = CoreTap.new
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
setup_test_formula("testball")
|
||||
@ -416,37 +373,6 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
begin
|
||||
Pathname("testball-1.0.big_sur.bottle.json").write(
|
||||
stub_hash(
|
||||
{
|
||||
"name": "testball",
|
||||
"version": "1.0",
|
||||
"path": "#{core_tap.path}/Formula/testball.rb",
|
||||
"cellar": "any_skip_relocation",
|
||||
"os": "big_sur",
|
||||
"filename": "hello-1.0.big_sur.bottle.tar.gz",
|
||||
"local_filename": "hello--1.0.big_sur.bottle.tar.gz",
|
||||
"sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
Pathname("testball-1.0.catalina.bottle.json").write(
|
||||
stub_hash(
|
||||
{
|
||||
"name": "testball",
|
||||
"version": "1.0",
|
||||
"path": "#{core_tap.path}/Formula/testball.rb",
|
||||
"cellar": "any_skip_relocation",
|
||||
"os": "catalina",
|
||||
"filename": "testball-1.0.catalina.bottle.tar.gz",
|
||||
"local_filename": "testball--1.0.catalina.bottle.tar.gz",
|
||||
"sha256": "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
"--merge",
|
||||
@ -455,14 +381,9 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
"testball-1.0.big_sur.bottle.json",
|
||||
"testball-1.0.catalina.bottle.json"
|
||||
}.to output("Error: --keep-old was passed but there was no existing bottle block!\n").to_stderr
|
||||
ensure
|
||||
FileUtils.rm_f "testball-1.0.catalina.bottle.json"
|
||||
FileUtils.rm_f "testball-1.0.big_sur.bottle.json"
|
||||
end
|
||||
end
|
||||
|
||||
it "updates the bottle block in a formula that already has a bottle block when using --keep-old" do
|
||||
core_tap = CoreTap.new
|
||||
core_tap.path.cd do
|
||||
system "git", "init"
|
||||
bottle_block = <<~EOS
|
||||
@ -478,37 +399,6 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
system "git", "commit", "-m", "testball 0.1"
|
||||
end
|
||||
|
||||
begin
|
||||
Pathname("testball-1.0.big_sur.bottle.json").write(
|
||||
stub_hash(
|
||||
{
|
||||
"name": "testball",
|
||||
"version": "1.0",
|
||||
"path": "#{core_tap.path}/Formula/testball.rb",
|
||||
"cellar": "any_skip_relocation",
|
||||
"os": "big_sur",
|
||||
"filename": "hello-1.0.big_sur.bottle.tar.gz",
|
||||
"local_filename": "hello--1.0.big_sur.bottle.tar.gz",
|
||||
"sha256": "a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
Pathname("testball-1.0.catalina.bottle.json").write(
|
||||
stub_hash(
|
||||
{
|
||||
"name": "testball",
|
||||
"version": "1.0",
|
||||
"path": "#{core_tap.path}/Formula/testball.rb",
|
||||
"cellar": "any_skip_relocation",
|
||||
"os": "catalina",
|
||||
"filename": "testball-1.0.catalina.bottle.tar.gz",
|
||||
"local_filename": "testball--1.0.catalina.bottle.tar.gz",
|
||||
"sha256": "5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
expect {
|
||||
brew "bottle",
|
||||
"--merge",
|
||||
@ -528,10 +418,6 @@ describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||
end
|
||||
EOS
|
||||
).to_stdout
|
||||
ensure
|
||||
FileUtils.rm_f "testball-1.0.catalina.bottle.json"
|
||||
FileUtils.rm_f "testball-1.0.big_sur.bottle.json"
|
||||
end
|
||||
|
||||
expect((core_tap.path/"Formula/testball.rb").read).to eq(
|
||||
<<~EOS,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user