summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2016-09-06 06:14:49 -0700
committerGitHub <noreply@github.com>2016-09-06 06:14:49 -0700
commitf9c67c9a8f33eb732fb75f2e7d702d0df8bb7e49 (patch)
tree5f1dfad4d1074665d01844277ec2353acd1cd2f2
parent471d72df4746cd69d853a8bccc06ae1e695baec0 (diff)
parentae1f3c95e3cfcf352071b56487877bfce2037e8a (diff)
downloadchef-f9c67c9a8f33eb732fb75f2e7d702d0df8bb7e49.tar.gz
Merge pull request #5250 from MsysTechnologiesllc/dh/add_timeout_during_package_removal
Added timeout during removing of windows package
-rw-r--r--lib/chef/provider/package/windows/exe.rb2
-rw-r--r--spec/unit/provider/package/windows/exe_spec.rb9
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/chef/provider/package/windows/exe.rb b/lib/chef/provider/package/windows/exe.rb
index 211845c073..44a2f19d1e 100644
--- a/lib/chef/provider/package/windows/exe.rb
+++ b/lib/chef/provider/package/windows/exe.rb
@@ -71,7 +71,7 @@ class Chef
uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) }
.map { |version| version.uninstall_string }.uniq.each do |uninstall_string|
Chef::Log.debug("Registry provided uninstall string for #{new_resource} is '#{uninstall_string}'")
- shell_out!(uninstall_command(uninstall_string), { returns: new_resource.returns })
+ shell_out!(uninstall_command(uninstall_string), { :timeout => new_resource.timeout, :returns => new_resource.returns })
end
end
diff --git a/spec/unit/provider/package/windows/exe_spec.rb b/spec/unit/provider/package/windows/exe_spec.rb
index b514f80a35..f18cbf3dca 100644
--- a/spec/unit/provider/package/windows/exe_spec.rb
+++ b/spec/unit/provider/package/windows/exe_spec.rb
@@ -122,6 +122,15 @@ describe Chef::Provider::Package::Windows::Exe do
end
end
+ context "When timeout value is passed" do
+ it "removes installed package and quotes uninstall string" do
+ new_resource.timeout = 300
+ allow(::File).to receive(:exist?).with("uninst_dir/uninst_file").and_return(true)
+ expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \"uninst_dir\/uninst_file\" \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, :timeout => 300, :returns => [0])
+ provider.remove_package
+ end
+ end
+
context "several packages installed with quoted uninstall strings" do
let(:uninstall_hash) do
[