summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-05-30 08:50:17 -0700
committerGitHub <noreply@github.com>2019-05-30 08:50:17 -0700
commit27b59997f556a70125b3d25c0b77da536c153caf (patch)
treea4f787e70076a25dfdd06b7bbb935442f5368431
parentba734ee29e7879f4b8388af06a4f232f8b29176f (diff)
parentc8ddcced6386b66d29aae7248bfaab2b40640cc8 (diff)
downloadchef-27b59997f556a70125b3d25c0b77da536c153caf.tar.gz
Merge pull request #8618 from chef/btm/fix-knife-exceptions
Raise knife exceptions when verbosity is 3 (-VVV)
-rw-r--r--lib/chef/knife.rb2
-rw-r--r--spec/unit/knife_spec.rb13
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index 2460dbaed8..48226bb344 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -475,7 +475,7 @@ class Chef
run
end
rescue Exception => e
- raise if raise_exception || Chef::Config[:verbosity] == 2
+ raise if raise_exception || ( Chef::Config[:verbosity] && Chef::Config[:verbosity] >= 2 )
humanize_exception(e)
exit 100
end
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index 080b2ffa29..169265c52d 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -372,11 +372,14 @@ describe Chef::Knife do
end
end
- it "does not humanize the exception if Chef::Config[:verbosity] is two" do
- Chef::Config[:verbosity] = 2
- allow(knife).to receive(:run).and_raise(Exception)
- expect(knife).not_to receive(:humanize_exception)
- expect { knife.run_with_pretty_exceptions }.to raise_error(Exception)
+ # -VV (2) is debug, -VVV (3) is trace
+ [ 2, 3 ].each do |verbosity|
+ it "does not humanize the exception if Chef::Config[:verbosity] is #{verbosity}" do
+ Chef::Config[:verbosity] = verbosity
+ allow(knife).to receive(:run).and_raise(Exception)
+ expect(knife).not_to receive(:humanize_exception)
+ expect { knife.run_with_pretty_exceptions }.to raise_error(Exception)
+ end
end
end