Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a --debug flag. Maybe chaning this latter to be --verbose or --…

…trace

Change-Id: I1fd04ebd413127ab04dae35fb3ee09642477b1e2
  • Loading branch information...
commit 2c6ab795a3b9c4b41484d94b38b5d94d43663374 1 parent 9b804e5
@vito vito authored
Showing with 29 additions and 1 deletion.
  1. +8 −0 lib/vmc/cli.rb
  2. +21 −1 spec/vmc/cli_spec.rb
View
8 lib/vmc/cli.rb
@@ -38,6 +38,9 @@ class CLI < Mothership
option :force, :desc => "Skip interaction when possible", :alias => "-f",
:type => :boolean, :default => proc { input[:script] }
+ option :debug, :desc => "Print full stack trace (instead of crash log)",
+ :type => :boolean, :default => false
+
option :quiet, :desc => "Simplify output format", :alias => "-q",
:type => :boolean, :default => proc { input[:script] }
@@ -137,6 +140,7 @@ def execute(cmd, argv, global = {})
msg << ": #{e}" unless e.to_s.empty?
msg << "\nFor more information, see #{VMC::CRASH_FILE}"
err msg
+ raise if debug?
end
def log_error(e)
@@ -173,6 +177,10 @@ def force?
input[:force]
end
+ def debug?
+ !!input[:debug]
+ end
+
def color_enabled?
input[:color]
end
View
22 spec/vmc/cli_spec.rb
@@ -4,8 +4,10 @@
let(:cmd) { Class.new(VMC::CLI).new }
describe '#execute' do
+ let(:inputs) { {} }
+
subject do
- stub(cmd).input { {} }
+ stub(cmd).input { inputs }
cmd.execute(nil, [])
end
@@ -15,6 +17,24 @@
mock(cmd).err "GET /foo timed out"
subject
end
+
+ context "when the debug flag is on" do
+ let(:inputs) { {:debug => true} }
+
+ it 'reraises' do
+ stub(cmd).precondition { raise StandardError.new }
+ expect { subject }.to raise_error(StandardError)
+ end
+ end
+
+ context "when the debug flag is off" do
+ it 'outputs the crash log message' do
+ stub(cmd).precondition { raise StandardError.new }
+ mock(cmd).err "StandardError: StandardError\nFor more information, see /Users/pivotal/workspace/vmc/vmc/spec/tmp/.vmc/crash"
+
+ expect { subject }.not_to raise_error(StandardError)
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.