Default to sudo: false for installer/uninstall :script.
This commit is contained in:
parent
b7e7b5b5c9
commit
2b4c3ee1d7
@ -16,7 +16,7 @@ module Hbc
|
|||||||
else
|
else
|
||||||
executable, script_arguments = self.class.read_script_arguments(artifact.script,
|
executable, script_arguments = self.class.read_script_arguments(artifact.script,
|
||||||
self.class.artifact_dsl_key.to_s,
|
self.class.artifact_dsl_key.to_s,
|
||||||
{ must_succeed: true, sudo: true },
|
{ must_succeed: true, sudo: false },
|
||||||
print_stdout: true)
|
print_stdout: true)
|
||||||
ohai "Running #{self.class.artifact_dsl_key} script #{executable}"
|
ohai "Running #{self.class.artifact_dsl_key} script #{executable}"
|
||||||
raise CaskInvalidError.new(@cask, "#{self.class.artifact_dsl_key} missing executable") if executable.nil?
|
raise CaskInvalidError.new(@cask, "#{self.class.artifact_dsl_key} missing executable") if executable.nil?
|
||||||
|
|||||||
@ -163,7 +163,7 @@ module Hbc
|
|||||||
def uninstall_script(directives, directive_name: :script)
|
def uninstall_script(directives, directive_name: :script)
|
||||||
executable, script_arguments = self.class.read_script_arguments(directives,
|
executable, script_arguments = self.class.read_script_arguments(directives,
|
||||||
"uninstall",
|
"uninstall",
|
||||||
{ must_succeed: true, sudo: true },
|
{ must_succeed: true, sudo: false },
|
||||||
{ print_stdout: true },
|
{ print_stdout: true },
|
||||||
directive_name)
|
directive_name)
|
||||||
|
|
||||||
|
|||||||
@ -216,36 +216,33 @@ shared_examples "#uninstall_phase or #zap_phase" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "using :script" do
|
[:script, :early_script].each do |script_type|
|
||||||
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_name}-script.rb") }
|
context "using #{script_type.inspect}" do
|
||||||
|
let(:fake_system_command) { Hbc::NeverSudoSystemCommand }
|
||||||
|
let(:token) { "with-#{artifact_name}-#{script_type}".tr("_", "-") }
|
||||||
|
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/#{token}.rb") }
|
||||||
let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }
|
let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }
|
||||||
|
|
||||||
it "is supported" do
|
it "is supported" do
|
||||||
Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname])
|
allow(fake_system_command).to receive(:run).with(any_args).and_call_original
|
||||||
|
|
||||||
Hbc::FakeSystemCommand.expects_command(
|
expect(fake_system_command).to receive(:run).with(
|
||||||
sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please"),
|
"/bin/chmod",
|
||||||
|
args: ["--", "+x", script_pathname],
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(fake_system_command).to receive(:run).with(
|
||||||
|
cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"),
|
||||||
|
args: ["--please"],
|
||||||
|
must_succeed: true,
|
||||||
|
print_stdout: true,
|
||||||
|
sudo: false,
|
||||||
)
|
)
|
||||||
|
|
||||||
InstallHelper.install_without_artifacts(cask)
|
InstallHelper.install_without_artifacts(cask)
|
||||||
subject
|
subject
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "using :early_script" do
|
|
||||||
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_name}-early-script.rb") }
|
|
||||||
let(:script_pathname) { cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool") }
|
|
||||||
|
|
||||||
it "is supported" do
|
|
||||||
Hbc::FakeSystemCommand.expects_command(%w[/bin/chmod -- +x] + [script_pathname])
|
|
||||||
|
|
||||||
Hbc::FakeSystemCommand.expects_command(
|
|
||||||
sudo(cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"), "--please"),
|
|
||||||
)
|
|
||||||
|
|
||||||
InstallHelper.install_without_artifacts(cask)
|
|
||||||
subject
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "using :login_item" do
|
context "using :login_item" do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user