2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-27 11:49:56 +00:00
|
|
|
require "cmd/shared_examples/args_parse"
|
2024-03-21 08:24:37 -07:00
|
|
|
require "dev-cmd/extract"
|
2019-03-27 11:49:56 +00:00
|
|
|
|
2024-03-21 08:24:37 -07:00
|
|
|
RSpec.describe Homebrew::DevCmd::Extract do
|
2024-03-21 19:48:13 -07:00
|
|
|
it_behaves_like "parseable arguments"
|
2019-03-27 11:49:56 +00:00
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
context "when extracting a formula" do
|
|
|
|
let!(:target) do
|
2024-08-10 13:35:20 -07:00
|
|
|
path = HOMEBREW_TAP_DIRECTORY/"homebrew/homebrew-foo"
|
2021-02-01 16:14:25 -05:00
|
|
|
(path/"Formula").mkpath
|
|
|
|
target = Tap.from_path(path)
|
2024-03-06 15:10:14 +01:00
|
|
|
core_tap = CoreTap.instance
|
2021-02-01 16:14:25 -05:00
|
|
|
core_tap.path.cd do
|
|
|
|
system "git", "init"
|
2021-07-17 13:45:59 +08:00
|
|
|
# Start with deprecated bottle syntax
|
|
|
|
setup_test_formula "testball", bottle_block: <<~EOS
|
|
|
|
|
|
|
|
bottle do
|
|
|
|
cellar :any
|
|
|
|
end
|
|
|
|
EOS
|
2021-02-01 16:14:25 -05:00
|
|
|
system "git", "add", "--all"
|
|
|
|
system "git", "commit", "-m", "testball 0.1"
|
2021-07-17 13:45:59 +08:00
|
|
|
# Replace with a valid formula for the next version
|
|
|
|
formula_file = setup_test_formula "testball"
|
2021-02-01 16:14:25 -05:00
|
|
|
contents = File.read(formula_file)
|
|
|
|
contents.gsub!("testball-0.1", "testball-0.2")
|
|
|
|
File.write(formula_file, contents)
|
|
|
|
system "git", "add", "--all"
|
|
|
|
system "git", "commit", "-m", "testball 0.2"
|
|
|
|
end
|
2024-03-07 16:20:20 +00:00
|
|
|
{ name: target.name, path: }
|
2018-08-24 11:42:11 -04:00
|
|
|
end
|
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
it "retrieves the most recent version of formula", :integration_test do
|
|
|
|
path = target[:path]/"Formula/testball@0.2.rb"
|
|
|
|
expect { brew "extract", "testball", target[:name] }
|
|
|
|
.to output(/^#{path}$/).to_stdout
|
|
|
|
.and not_to_output.to_stderr
|
|
|
|
.and be_a_success
|
|
|
|
expect(path).to exist
|
2023-12-14 02:52:30 +00:00
|
|
|
expect(Formulary.factory(path).version).to eq "0.2"
|
2021-02-01 16:14:25 -05:00
|
|
|
end
|
2018-08-24 11:42:11 -04:00
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
it "retrieves the specified version of formula", :integration_test do
|
|
|
|
path = target[:path]/"Formula/testball@0.1.rb"
|
|
|
|
expect { brew "extract", "testball", target[:name], "--version=0.1" }
|
|
|
|
.to output(/^#{path}$/).to_stdout
|
|
|
|
.and not_to_output.to_stderr
|
|
|
|
.and be_a_success
|
|
|
|
expect(path).to exist
|
2023-12-14 02:52:30 +00:00
|
|
|
expect(Formulary.factory(path).version).to eq "0.1"
|
2021-02-01 16:14:25 -05:00
|
|
|
end
|
2018-08-24 11:42:11 -04:00
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
it "retrieves the compatible version of formula", :integration_test do
|
|
|
|
path = target[:path]/"Formula/testball@0.rb"
|
|
|
|
expect { brew "extract", "testball", target[:name], "--version=0" }
|
|
|
|
.to output(/^#{path}$/).to_stdout
|
|
|
|
.and not_to_output.to_stderr
|
|
|
|
.and be_a_success
|
|
|
|
expect(path).to exist
|
2023-12-14 02:52:30 +00:00
|
|
|
expect(Formulary.factory(path).version).to eq "0.2"
|
2021-02-01 16:14:25 -05:00
|
|
|
end
|
2018-08-24 11:42:11 -04:00
|
|
|
end
|
2018-08-20 09:21:00 -04:00
|
|
|
end
|