Skip to content

Commit

Permalink
Exit with a non-zero value if site generation fails (issue #103)
Browse files Browse the repository at this point in the history
  • Loading branch information
lance committed Jun 22, 2012
1 parent 7bcdc97 commit b66553f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion bin/awestruct
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ $: << File.dirname(__FILE__) + '/../lib'
require 'rubygems'
require 'awestruct/cli/invoker'

Awestruct::CLI::Invoker.new( ARGV ).invoke!
invoker = Awestruct::CLI::Invoker.new( ARGV )
invoker.invoke!

invoker.success ? exit 0 : exit -1

This comment has been minimized.

Copy link
@aslakknutsen

aslakknutsen Jun 26, 2012

Member

This change cause:

../awestruct/bin/awestruct:11: syntax error, unexpected tINTEGER, expecting kDO or '{' or '('
invoker.success ? exit 0 : exit -1

Ubuntu, ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

This works tho: exit (invoker.success ? 0 : -1)

This comment has been minimized.

Copy link
@lance

lance Jun 26, 2012

Author Member

Ugh - sorry about that. It was hard to test exit values in an rspec test.

1 change: 1 addition & 0 deletions lib/awestruct/cli/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def run()
rescue =>e
puts e
puts e.backtrace
return false
end
end
end
Expand Down
5 changes: 4 additions & 1 deletion lib/awestruct/cli/invoker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Invoker

attr_reader :config
attr_reader :profile
attr_reader :success

def initialize(*options)
options = options.flatten
Expand All @@ -26,6 +27,7 @@ def initialize(*options)
end
@threads = []
@profile = nil
@success = true
end

def invoke!
Expand All @@ -42,6 +44,7 @@ def invoke!
invoke_auto() if ( options.auto )

wait_for_completion()
success
end

def load_profile()
Expand Down Expand Up @@ -90,7 +93,7 @@ def invoke_force()
end

def invoke_generate()
Awestruct::CLI::Generate.new( config, options.profile, options.base_url, 'http://localhost:4242', options.force ).run
@success = Awestruct::CLI::Generate.new( config, options.profile, options.base_url, 'http://localhost:4242', options.force ).run
end

def invoke_deploy()
Expand Down
1 change: 1 addition & 0 deletions lib/awestruct/cli/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

module Awestruct
module CLI

class Options

attr_accessor :generate
Expand Down
File renamed without changes.
7 changes: 5 additions & 2 deletions spec/invoker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@
invoker.invoke!
end

it "should return a non-zero value on failure" do
pending "A fix for issue #103"
it "should return false on failure" do
generator = mock
Awestruct::CLI::Generate.should_receive( :new ).and_return( generator )
generator.should_receive( :run ).and_return( false )
Awestruct::CLI::Invoker.new( '--generate' ).invoke!.should be_false
end


Expand Down

0 comments on commit b66553f

Please sign in to comment.