diff options
author | Bryan McLellan <btm@loftninjas.org> | 2019-05-30 09:17:42 -0400 |
---|---|---|
committer | Bryan McLellan <btm@loftninjas.org> | 2019-05-30 13:41:40 -0400 |
commit | bdbb38699b7d6c7837dc901a646cb57da14a80df (patch) | |
tree | d3e243d22ea5bcb3a79a71ab0d19d57db2a42def | |
parent | abc4b4ffdc19b4fb25eb7c7b84acd9ce3e78b420 (diff) | |
download | chef-bdbb38699b7d6c7837dc901a646cb57da14a80df.tar.gz |
Raise knife exceptions when verbosity is 3 (-VVV)
Fixes #8433
When we added trace this check wasn't changed, which means you only saw
the stacktrace for 2 (-VV) but not for 3 (-VVV)
Signed-off-by: Bryan McLellan <btm@loftninjas.org>
-rw-r--r-- | lib/chef/knife.rb | 2 | ||||
-rw-r--r-- | spec/unit/knife_spec.rb | 13 |
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index 6051f9fd66..f645b85712 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -446,7 +446,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 67251b2cd9..fceb00aa09 100644 --- a/spec/unit/knife_spec.rb +++ b/spec/unit/knife_spec.rb @@ -344,11 +344,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 |