2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-23 06:04:02 +01:00
|
|
|
require "extend/ENV"
|
2024-04-01 10:09:48 -07:00
|
|
|
require "cmd/reinstall"
|
2019-03-28 08:35:36 +00:00
|
|
|
require "cmd/shared_examples/args_parse"
|
2017-02-23 06:04:02 +01:00
|
|
|
|
2024-04-01 10:09:48 -07:00
|
|
|
RSpec.describe Homebrew::Cmd::Reinstall do
|
2019-03-28 08:35:36 +00:00
|
|
|
it_behaves_like "parseable arguments"
|
2017-02-23 06:04:02 +01:00
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
it "reinstalls a Formula", :integration_test do
|
2019-03-28 08:35:36 +00:00
|
|
|
install_test_formula "testball"
|
|
|
|
foo_dir = HOMEBREW_CELLAR/"testball/0.1/bin"
|
2017-02-23 06:04:02 +01:00
|
|
|
expect(foo_dir).to exist
|
2024-09-24 10:15:34 +01:00
|
|
|
FileUtils.rm_r(foo_dir)
|
2017-02-23 06:04:02 +01:00
|
|
|
|
2017-02-25 09:01:24 +01:00
|
|
|
expect { brew "reinstall", "testball" }
|
2019-03-28 08:35:36 +00:00
|
|
|
.to output(/Reinstalling testball/).to_stdout
|
2017-02-23 06:04:02 +01:00
|
|
|
.and not_to_output.to_stderr
|
|
|
|
.and be_a_success
|
|
|
|
|
|
|
|
expect(foo_dir).to exist
|
|
|
|
end
|
2025-03-06 21:27:35 -05:00
|
|
|
|
|
|
|
it "reinstalls a Formula with ask input", :integration_test do
|
|
|
|
install_test_formula "testball"
|
|
|
|
foo_dir = HOMEBREW_CELLAR/"testball/0.1/bin"
|
|
|
|
expect(foo_dir).to exist
|
|
|
|
FileUtils.rm_r(foo_dir)
|
|
|
|
|
|
|
|
expect { brew "reinstall", "--ask", "testball" }
|
|
|
|
.to output(/.*Formula\s*\(1\):\s*testball.*/).to_stdout
|
2025-03-06 23:02:17 -05:00
|
|
|
.and not_to_output.to_stderr
|
|
|
|
.and be_a_success
|
2025-03-06 21:27:35 -05:00
|
|
|
|
|
|
|
expect(foo_dir).to exist
|
|
|
|
end
|
2025-07-23 21:13:22 +01:00
|
|
|
|
|
|
|
it "refuses to reinstall a forbidden formula", :integration_test do
|
|
|
|
install_test_formula "testball"
|
|
|
|
foo_dir = HOMEBREW_CELLAR/"testball/0.1/bin"
|
|
|
|
expect(foo_dir).to exist
|
|
|
|
FileUtils.rm_r(foo_dir)
|
|
|
|
|
|
|
|
expect { brew "reinstall", "testball", { "HOMEBREW_FORBIDDEN_FORMULAE" => "testball" } }
|
|
|
|
.to not_to_output(%r{#{HOMEBREW_CELLAR}/testball/0\.1}o).to_stdout
|
|
|
|
.and output(/testball was forbidden/).to_stderr
|
|
|
|
.and be_a_failure
|
|
|
|
|
|
|
|
expect(foo_dir).not_to exist
|
|
|
|
end
|
2017-02-23 06:04:02 +01:00
|
|
|
end
|