Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Keep result code in Cocaine::CommandLine#exit_status
  • Loading branch information
Alban Peignier committed Feb 25, 2012
1 parent 4eb18d2 commit bfe0ba6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/cocaine/command_line.rb
Expand Up @@ -4,6 +4,8 @@ class << self
attr_accessor :path, :logger
end

attr_reader :exit_status

def initialize(binary, params = "", options = {})
@binary = binary.dup
@params = params.dup
Expand Down Expand Up @@ -31,6 +33,8 @@ def run
end
rescue Errno::ENOENT
raise Cocaine::CommandNotFoundError
ensure
@exit_status = $?.exitstatus
end
if $?.exitstatus == 127
raise Cocaine::CommandNotFoundError
Expand Down
9 changes: 9 additions & 0 deletions spec/cocaine/command_line_spec.rb
Expand Up @@ -142,6 +142,15 @@
end
end

it "should keep result code in #exitstatus" do
cmd = Cocaine::CommandLine.new("convert")
cmd.class.stubs(:"`").with("convert").returns(:correct_value)
with_exitstatus_returning(1) do
cmd.run rescue nil
end
cmd.exit_status.should == 1
end

it "detects that the system is unix" do
Cocaine::CommandLine.new("convert").unix?.should be_true
end
Expand Down

0 comments on commit bfe0ba6

Please sign in to comment.